From f14684c5cb2241665e9ea152f842632b70f4296b Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 5 May 2017 16:58:18 +0530 Subject: get_define: Add prefix before ifndef block Otherwise the compiler will warn about macros being redefined. --- mesonbuild/compilers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 3d2cd96..f4439dc 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -1139,10 +1139,10 @@ class CCompiler(Compiler): delim = '"MESON_GET_DEFINE_DELIMITER"' fargs = {'prefix': prefix, 'define': dname, 'delim': delim} code = ''' + {prefix} #ifndef {define} # define {define} #endif - {prefix} {delim}\n{define}''' args = self._get_compiler_check_args(env, extra_args, dependencies, mode='preprocess').to_native() -- cgit v1.1 From 2b8196a1c8793fbdd4a41477d77be3fcd0e8287e Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 5 May 2017 16:53:45 +0530 Subject: tests/common/140: Add a test for PR #1738 The bug is only encountered with headers in the default compiler search path, so use zlib.h since that is commonly available. See: https://github.com/mesonbuild/meson/issues/1726 --- test cases/common/140 get define/meson.build | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test cases/common/140 get define/meson.build b/test cases/common/140 get define/meson.build index 339e37a..9342340 100644 --- a/test cases/common/140 get define/meson.build +++ b/test cases/common/140 get define/meson.build @@ -20,6 +20,15 @@ foreach lang : ['c', 'cpp'] error('Please report a bug and help us improve support for this platform') endif + if cc.find_library('z', required : false).found() + # When a C file containing #include is pre-processed and foo.h is + # found in the compiler's default search path, GCC inserts an extra comment + # between the delimiter and the define which causes a parsing error. + # https://github.com/mesonbuild/meson/issues/1726 + ver = cc.get_define('ZLIB_VER_MAJOR', prefix : '#include ') + assert(ver == '1', 'ZLIB_VER_MAJOR value is "@0@" instead of "1"'.format(ver)) + endif + # Check that an undefined value is empty. have = cc.get_define('MESON_FAIL_VALUE') assert(have == '', 'MESON_FAIL_VALUE value is "@0@" instead of ""'.format(have)) -- cgit v1.1 From 7dccf0c5adc8f92192ffe8688abf29a51eb86bc5 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 5 May 2017 17:42:30 +0530 Subject: compilers: Don't add line comments to pre-processed output We never use preprocessed output anywhere except compiler checks, so we don't care about the debugging information that it adds. Just always disable it. Closes https://github.com/mesonbuild/meson/issues/1726 --- mesonbuild/compilers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index f4439dc..406c719 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -782,7 +782,7 @@ class CCompiler(Compiler): return self.exelist[:] def get_preprocess_only_args(self): - return ['-E'] + return ['-E', '-P'] def get_compile_only_args(self): return ['-c'] @@ -2135,7 +2135,7 @@ class VisualStudioCCompiler(CCompiler): return ['/FI' + base, '/Yu' + base, '/Fp' + os.path.join(pch_dir, pchname)] def get_preprocess_only_args(self): - return ['/E'] + return ['/EP'] def get_compile_only_args(self): return ['/c'] -- cgit v1.1