diff options
author | Michael Hirsch, Ph.D <10931741+scivision@users.noreply.github.com> | 2019-11-18 15:21:37 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-11-18 22:21:36 +0200 |
commit | 83b4e981c4dd8b8ea521a6150a34636d10a67211 (patch) | |
tree | 3ac84e307e6a2589073a7542a0d7127738f09576 /mesonbuild/compilers | |
parent | 0435691e83fb7172e2a9635d2eb32d5521089916 (diff) | |
download | meson-83b4e981c4dd8b8ea521a6150a34636d10a67211.zip meson-83b4e981c4dd8b8ea521a6150a34636d10a67211.tar.gz meson-83b4e981c4dd8b8ea521a6150a34636d10a67211.tar.bz2 |
Use strict function prototypes
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r-- | mesonbuild/compilers/c.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/cpp.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/cuda.py | 2 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 38 | ||||
-rw-r--r-- | mesonbuild/compilers/objc.py | 2 | ||||
-rw-r--r-- | mesonbuild/compilers/objcpp.py | 2 |
6 files changed, 26 insertions, 26 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 7c46627..db7abf0 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -59,14 +59,14 @@ class CCompiler(CLikeCompiler, Compiler): return ['-nostdinc'] def sanity_check(self, work_dir, environment): - code = 'int main() { int class=0; return class; }\n' + code = 'int main(void) { int class=0; return class; }\n' return self.sanity_check_impl(work_dir, environment, 'sanitycheckc.c', code) def has_header_symbol(self, hname, symbol, prefix, env, *, extra_args=None, dependencies=None): fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol} t = '''{prefix} #include <{header}> - int main () {{ + int main(void) {{ /* If it's not defined as a macro, try to use as a symbol */ #ifndef {symbol} {symbol}; diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 67a26dc..6d45a84 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -73,7 +73,7 @@ class CPPCompiler(CLikeCompiler, Compiler): return ['-nostdinc++'] def sanity_check(self, work_dir, environment): - code = 'class breakCCompiler;int main() { return 0; }\n' + code = 'class breakCCompiler;int main(void) { return 0; }\n' return self.sanity_check_impl(work_dir, environment, 'sanitycheckcpp.cc', code) def get_compiler_check_args(self): @@ -96,7 +96,7 @@ class CPPCompiler(CLikeCompiler, Compiler): t = '''{prefix} #include <{header}> using {symbol}; - int main () {{ return 0; }}''' + int main(void) {{ return 0; }}''' return self.compiles(t.format(**fargs), env, extra_args=extra_args, dependencies=dependencies) diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 4ca8f4e..91dde0c 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -174,7 +174,7 @@ class CudaCompiler(Compiler): t = '''{prefix} #include <{header}> using {symbol}; - int main () {{ return 0; }}''' + int main(void) {{ return 0; }}''' return self.compiles(t.format(**fargs), env, extra_args, dependencies) def get_options(self): diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 5d50b7d..ce3d9d7 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -258,7 +258,7 @@ class CLikeCompiler: raise mesonlib.EnvironmentException('Executables created by {0} compiler {1} are not runnable.'.format(self.language, self.name_string())) def sanity_check(self, work_dir, environment): - code = 'int main() { int class=0; return class; }\n' + code = 'int main(void) { int class=0; return class; }\n' return self.sanity_check_impl(work_dir, environment, 'sanitycheckc.c', code) def check_header(self, hname, prefix, env, *, extra_args=None, dependencies=None): @@ -285,7 +285,7 @@ class CLikeCompiler: fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol} t = '''{prefix} #include <{header}> - int main () {{ + int main(void) {{ /* If it's not defined as a macro, try to use as a symbol */ #ifndef {symbol} {symbol}; @@ -398,7 +398,7 @@ class CLikeCompiler: fargs = {'prefix': prefix, 'expression': expression} t = '''#include <stdio.h> {prefix} - int main() {{ static int a[1-2*!({expression})]; a[0]=0; return 0; }}''' + int main(void) {{ static int a[1-2*!({expression})]; a[0]=0; return 0; }}''' return self.compiles(t.format(**fargs), env, extra_args=extra_args, dependencies=dependencies)[0] @@ -458,7 +458,7 @@ class CLikeCompiler: fargs = {'prefix': prefix, 'expression': expression} t = '''#include<stdio.h> {prefix} - int main() {{ + int main(void) {{ printf("%ld\\n", (long)({expression})); return 0; }};''' @@ -476,7 +476,7 @@ class CLikeCompiler: fargs = {'prefix': prefix, 'type': typename} t = '''#include <stdio.h> {prefix} - int main() {{ + int main(void) {{ {type} something; return 0; }}''' @@ -494,7 +494,7 @@ class CLikeCompiler: dependencies=dependencies) t = '''#include<stdio.h> {prefix} - int main() {{ + int main(void) {{ printf("%ld\\n", (long)(sizeof({type}))); return 0; }};''' @@ -512,7 +512,7 @@ class CLikeCompiler: fargs = {'prefix': prefix, 'type': typename} t = '''#include <stdio.h> {prefix} - int main() {{ + int main(void) {{ {type} something; return 0; }}''' @@ -541,7 +541,7 @@ class CLikeCompiler: char c; {type} target; }}; - int main() {{ + int main(void) {{ printf("%d", (int)offsetof(struct tmp, target)); return 0; }}''' @@ -591,7 +591,7 @@ class CLikeCompiler: fargs = {'prefix': prefix, 'f': fname, 'cast': cast, 'fmt': fmt} code = '''{prefix} #include <stdio.h> - int main() {{ + int main(void) {{ printf ("{fmt}", {cast} {f}()); return 0; }}'''.format(**fargs) @@ -634,11 +634,11 @@ class CLikeCompiler: #ifdef __cplusplus extern "C" #endif - char {func} (); + char {func} (void); ''' # The actual function call main = ''' - int main () {{ + int main(void) {{ return {func} (); }}''' return head, main @@ -657,7 +657,7 @@ class CLikeCompiler: # Just taking the address or comparing it to void is not enough because # compilers are smart enough to optimize it away. The resulting binary # is not run so we don't care what the return value is. - main = '''\nint main() {{ + main = '''\nint main(void) {{ void *a = (void*) &{func}; long b = (long) a; return (int) b; @@ -729,7 +729,7 @@ class CLikeCompiler: # can just directly use the __has_builtin() macro. fargs['no_includes'] = '#include' not in prefix t = '''{prefix} - int main() {{ + int main(void) {{ #ifdef __has_builtin #if !__has_builtin(__builtin_{func}) #error "__builtin_{func} not found" @@ -761,7 +761,7 @@ class CLikeCompiler: members += '{}.{};\n'.format(fargs['name'], member) fargs['members'] = members t = '''{prefix} - void bar() {{ + void bar(void) {{ {type} {name}; {members} }};''' @@ -771,7 +771,7 @@ class CLikeCompiler: def has_type(self, typename, prefix, env, extra_args, dependencies=None): fargs = {'prefix': prefix, 'type': typename} t = '''{prefix} - void bar() {{ + void bar(void) {{ sizeof({type}); }};''' return self.compiles(t.format(**fargs), env, extra_args=extra_args, @@ -785,7 +785,7 @@ class CLikeCompiler: code = '''#ifdef __cplusplus extern "C" { #endif - void ''' + symbol_name.decode() + ''' () {} + void ''' + symbol_name.decode() + ''' (void) {} #ifdef __cplusplus } #endif @@ -993,7 +993,7 @@ class CLikeCompiler: return value[:] def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED): - code = 'int main() { return 0; }' + code = 'int main(void) { return 0; }' return self.find_library_impl(libname, env, extra_dirs, code, libtype) def find_framework_paths(self, env): @@ -1023,7 +1023,7 @@ class CLikeCompiler: return paths def find_framework_real(self, name, env, extra_dirs, allow_system): - code = 'int main() { return 0; }' + code = 'int main(void) { return 0; }' link_args = [] for d in extra_dirs: link_args += ['-F' + d] @@ -1102,7 +1102,7 @@ class CLikeCompiler: # false positive. args = self.linker.fatal_warnings() + args args = self.linker_to_compiler_args(args) - code = 'int main() { return 0; }' + code = 'int main(void) { return 0; }' return self.has_arguments(args, env, code, mode='link') @staticmethod diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index 58f3ec5..f69c57c 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -48,7 +48,7 @@ class ObjCCompiler(CLikeCompiler, Compiler): extra_flags += environment.coredata.get_external_link_args(self.for_machine, self.language) with open(source_name, 'w') as ofile: ofile.write('#import<stddef.h>\n' - 'int main() { return 0; }\n') + 'int main(void) { return 0; }\n') pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name]) pc.wait() if pc.returncode != 0: diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index 5dab8b0..76cda7b 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -48,7 +48,7 @@ class ObjCPPCompiler(CLikeCompiler, Compiler): with open(source_name, 'w') as ofile: ofile.write('#import<stdio.h>\n' 'class MyClass;' - 'int main() { return 0; }\n') + 'int main(void) { return 0; }\n') pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name]) pc.wait() if pc.returncode != 0: |