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 #958pull/1006/head
parent
87f07cdf3d
commit
f6dfd36239
2 changed files with 44 additions and 16 deletions
@ -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 |
||||
|
||||
|
||||
|
Loading…
Reference in new issue