diff options
| author | Bruce Richardson <[email protected]> | 2022-02-15 17:30:29 +0000 |
|---|---|---|
| committer | Thomas Monjalon <[email protected]> | 2022-02-22 15:26:15 +0100 |
| commit | 1ee492bdc4ffeb392f6e7cc0386793c3e53ebb0f (patch) | |
| tree | 3350f0f623cbbd29d735b0e3a4e1ca1c421681d3 /buildtools | |
| parent | b232b2aa212be9a7f127ad368c40faf28989f678 (diff) | |
buildtools/chkincs: check missing C++ guards
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 <[email protected]>
Acked-by: Tyler Retzlaff <[email protected]>
Diffstat (limited to 'buildtools')
| -rw-r--r-- | buildtools/chkincs/meson.build | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.build index 9bb19c9ba3..378c2f19ef 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: '@[email protected]', arguments: ['@INPUT@', '@OUTPUT@']) |
