build: Add feature test flags to project-wide preprocessor flags

Rather than defining them piecemeal in each C and H file, and having
problems with headers being included in different orders so that
`_POSIX_C_SOURCE` gets a value which is too low, just define the feature
test flags in `meson.build`.

See `man 7 feature_test_macros`.

This is useful for when building sysprof as a subproject beneath a
project which doesn’t define these macros, or which targets an older C
standard than `gnu11`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall
2020-07-06 11:25:32 +01:00
parent 100a4df9fa
commit 50679dba04

View File

@ -87,7 +87,10 @@ add_project_arguments([
'-I' + meson.build_root(), # config.h
], language: 'c')
global_c_args = []
global_c_args = [
'-D_GNU_SOURCE',
'-D_POSIX_C_SOURCE=200809L',
]
test_c_args = [
'-Wcast-align',
'-Wdeclaration-after-statement',