diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-01-24 02:55:18 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-01-26 09:16:48 +0530 |
commit | 748fe80423b56ea52a5dbb26f84cfedd5b416b8e (patch) | |
tree | 5040f4f00cb984b2283eded8136b4952cac855d8 /mesonbuild/compilers.py | |
parent | 3433fc54c916d41a26e2e214818bf0fda896cf04 (diff) | |
download | meson-748fe80423b56ea52a5dbb26f84cfedd5b416b8e.zip meson-748fe80423b56ea52a5dbb26f84cfedd5b416b8e.tar.gz meson-748fe80423b56ea52a5dbb26f84cfedd5b416b8e.tar.bz2 |
compilers: Add prefix before limits.h in has_function checks
prefix might define _GNU_SOURCE, which *must* be defined before your
first include of limits.h, so we must define it first.
There's not really any downsides to including limits.h after the
prefix.
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r-- | mesonbuild/compilers.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 0d30ff8..6e60ba1 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -949,12 +949,13 @@ class CCompiler(Compiler): """ # Define the symbol to something else since it is defined by the # includes or defines listed by the user or by the compiler. This may - # include, for instance _GNU_SOURCE. Then, undef the symbol to get rid - # of it completely. + # include, for instance _GNU_SOURCE which must be defined before + # limits.h, which includes features.h + # Then, undef the symbol to get rid of it completely. head = ''' #define {func} meson_disable_define_of_{func} - #include <limits.h> {prefix} + #include <limits.h> #undef {func} ''' # Override any GCC internal prototype and declare our own definition for @@ -980,8 +981,9 @@ class CCompiler(Compiler): user for the function prototype while checking if a function exists. """ # Add the 'prefix', aka defines, includes, etc that the user provides - # This may include, for instance _GNU_SOURCE - head = '#include <limits.h>\n{prefix}\n' + # This may include, for instance _GNU_SOURCE which must be defined + # before limits.h, which includes features.h + head = '{prefix}\n#include <limits.h>\n' # We don't know what the function takes or returns, so return it as an int. # Just taking the address or comparing it to void is not enough because # compilers are smart enough to optimize it away. The resulting binary |