diff options
| author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-11-08 15:01:52 +0530 |
|---|---|---|
| committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-11-08 15:42:15 +0530 |
| commit | f6dfd362393fb1e999bcc0dbc7ef65c48d8b204f (patch) | |
| tree | 8f72826860356316f8bc62d4f0a748219ee8ed83 /test cases/common | |
| parent | 87f07cdf3db9923b41ac23d27d8e017c8c57ecc3 (diff) | |
| download | meson-f6dfd362393fb1e999bcc0dbc7ef65c48d8b204f.tar.gz | |
has_header_symbol: Make it work with C++ compilers
Need to pass -fpermissive to force C++ compilers to only warn about our
non-conformant code that tests for a symbol being defined.
Also do a simple #ifdef check first in has_header_symbol to allow
arbitrary macros to be detected which would not have been detected
earlier. This follows what AC_CHECK_DECL does.
Closes #958
Diffstat (limited to 'test cases/common')
| -rw-r--r-- | test cases/common/111 has header symbol/meson.build | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/test cases/common/111 has header symbol/meson.build b/test cases/common/111 has header symbol/meson.build index e0afb4212..c62e7c044 100644 --- a/test cases/common/111 has header symbol/meson.build +++ b/test cases/common/111 has header symbol/meson.build @@ -1,18 +1,23 @@ -project('has header symbol', 'c') +project('has header symbol', 'c', 'cpp') cc = meson.get_compiler('c') +cpp = meson.get_compiler('cpp') -assert (cc.has_header_symbol('stdio.h', 'int'), 'base types should always be available') -assert (cc.has_header_symbol('stdio.h', 'printf'), 'printf function not found') -assert (cc.has_header_symbol('stdio.h', 'FILE'), 'FILE structure not found') -assert (cc.has_header_symbol('limits.h', 'INT_MAX'), 'INT_MAX define not found') -assert (not cc.has_header_symbol('limits.h', 'guint64'), 'guint64 is not defined in limits.h') -assert (not cc.has_header_symbol('stdlib.h', 'FILE'), 'FILE structure is defined in stdio.h, not stdlib.h') -assert (not cc.has_header_symbol('stdlol.h', 'printf'), 'stdlol.h shouldn\'t exist') -assert (not cc.has_header_symbol('stdlol.h', 'int'), 'shouldn\'t be able to find "int" with invalid header') +foreach comp : [cc, cpp] + assert (comp.has_header_symbol('stdio.h', 'int'), 'base types should always be available') + assert (comp.has_header_symbol('stdio.h', 'printf'), 'printf function not found') + assert (comp.has_header_symbol('stdio.h', 'FILE'), 'FILE structure not found') + assert (comp.has_header_symbol('limits.h', 'INT_MAX'), 'INT_MAX define not found') + assert (not comp.has_header_symbol('limits.h', 'guint64'), 'guint64 is not defined in limits.h') + assert (not comp.has_header_symbol('stdlib.h', 'FILE'), 'FILE structure is defined in stdio.h, not stdlib.h') + assert (not comp.has_header_symbol('stdlol.h', 'printf'), 'stdlol.h shouldn\'t exist') + assert (not comp.has_header_symbol('stdlol.h', 'int'), 'shouldn\'t be able to find "int" with invalid header') +endforeach # This is likely only available on Glibc, so just test for it if cc.has_function('ppoll') assert (not cc.has_header_symbol('poll.h', 'ppoll'), 'ppoll should not be accessible without _GNU_SOURCE') assert (cc.has_header_symbol('poll.h', 'ppoll', prefix : '#define _GNU_SOURCE'), 'ppoll should be accessible with _GNU_SOURCE') endif + + |
