DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH 3/3] buildtools/chkincs: add checks for missing C++ guards
Date: Tue, 15 Feb 2022 17:30:29 +0000	[thread overview]
Message-ID: <20220215173029.1893710-4-bruce.richardson@intel.com> (raw)
In-Reply-To: <20220215173029.1893710-1-bruce.richardson@intel.com>

Simply compiling a C header with a C++ compiler is not enough to flag
missing 'extern "C"' guards. To catch missing guards, we can just use a
simple grep for the 'extern "C"' part, and error out if any files have a
miss.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---

Depends-on: series-21685 ("add missing C++ guards")
---
 buildtools/chkincs/meson.build | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.build
index 9442235200..77ef59fb13 100644
--- a/buildtools/chkincs/meson.build
+++ b/buildtools/chkincs/meson.build
@@ -37,6 +37,16 @@ if not add_languages('cpp', required: false)
     subdir_done()
 endif

+# check for extern C in files, since this is not detected as an error by the compiler
+grep = find_program('grep', required: false)
+if grep.found()
+    errlist = run_command([grep, '--files-without-match', '^extern "C"', dpdk_chkinc_headers],
+            check: false, capture: true).stdout().split()
+    if errlist != []
+        error('Files missing C++ \'extern "C"\' guards:\n- ' + '\n- '.join(errlist))
+    endif
+endif
+
 gen_cpp_files = generator(gen_c_file_for_header,
         output: '@BASENAME@.cpp',
         arguments: ['@INPUT@', '@OUTPUT@'])
--
2.32.0


  parent reply	other threads:[~2022-02-15 17:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 17:30 [PATCH 0/3] extend C++ compatibility checks Bruce Richardson
2022-02-15 17:30 ` [PATCH 1/3] ethdev: fix missing cast for C++ compatibility Bruce Richardson
2022-02-16 10:32   ` Ferruh Yigit
2022-02-16 11:01     ` Bruce Richardson
2022-02-15 17:30 ` [PATCH 2/3] buildtools/chkincs: check sdk headers " Bruce Richardson
2022-02-15 17:30 ` Bruce Richardson [this message]
2022-02-17  8:06 ` [PATCH 0/3] extend C++ compatibility checks Tyler Retzlaff
2022-02-22 14:21   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220215173029.1893710-4-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).