git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ba3d93b)
meson: Move C99 test earlier
2025年8月18日 05:35:55 +0000 (07:35 +0200)
2025年8月18日 05:42:39 +0000 (07:42 +0200)
Move the test for compiler options for C99 earlier in meson.build,
before we make use of the compiler for other tests. That way, if any
command-line options are needed, subsequent tests will also use them.
This is at the moment a theoretical problem, but it seems better to
get this correct. It also matches the order in the Autoconf-based
build more closely.

Discussion: https://www.postgresql.org/message-id/flat/01a69441-af54-4822-891b-ca28e05b215a@eisentraut.org


diff --git a/meson.build b/meson.build
index 30e0edda3e7932ba5e229e2ebfc58aa86afdf7c9..a87eb913fff30eb73a9d1f1a2d33e9924f791173 100644 (file)
--- a/meson.build
+++ b/meson.build
@@ -550,6 +550,48 @@ dir_doc_extension = dir_doc / 'extension'
# used, they need to be added to test_c_args as well.
###############################################################
+# Do we need -std=c99 to compile C99 code? We don't want to add -std=c99
+# unnecessarily, because we optionally rely on newer features.
+c99_test = '''
+#include <stdbool.h>
+#include <complex.h>
+#include <tgmath.h>
+#include <inttypes.h>
+
+struct named_init_test {
+ int a;
+ int b;
+};
+
+extern void structfunc(struct named_init_test);
+
+int main(int argc, char **argv)
+{
+ struct named_init_test nit = {
+ .a = 3,
+ .b = 5,
+ };
+
+ for (int loop_var = 0; loop_var < 3; loop_var++)
+ {
+ nit.a += nit.b;
+ }
+
+ structfunc((struct named_init_test){1, 0});
+
+ return nit.a != 0;
+}
+'''
+
+if not cc.compiles(c99_test, name: 'c99')
+ if cc.compiles(c99_test, name: 'c99 with -std=c99', args: ['-std=c99'])
+ cflags += '-std=c99'
+ else
+ error('C compiler does not support C99')
+ endif
+endif
+
+
postgres_inc = [include_directories(postgres_inc_d)]
test_lib_d = postgres_lib_d
test_c_args = cppflags + cflags
@@ -1704,49 +1746,6 @@ endif
# Compiler tests
###############################################################
-# Do we need -std=c99 to compile C99 code? We don't want to add -std=c99
-# unnecessarily, because we optionally rely on newer features.
-c99_test = '''
-#include <stdbool.h>
-#include <complex.h>
-#include <tgmath.h>
-#include <inttypes.h>
-
-struct named_init_test {
- int a;
- int b;
-};
-
-extern void structfunc(struct named_init_test);
-
-int main(int argc, char **argv)
-{
- struct named_init_test nit = {
- .a = 3,
- .b = 5,
- };
-
- for (int loop_var = 0; loop_var < 3; loop_var++)
- {
- nit.a += nit.b;
- }
-
- structfunc((struct named_init_test){1, 0});
-
- return nit.a != 0;
-}
-'''
-
-if not cc.compiles(c99_test, name: 'c99', args: test_c_args)
- if cc.compiles(c99_test, name: 'c99 with -std=c99',
- args: test_c_args + ['-std=c99'])
- test_c_args += '-std=c99'
- cflags += '-std=c99'
- else
- error('C compiler does not support C99')
- endif
-endif
-
if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
endif
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /