Skip to content

Commit 4a40380

Browse files
committed
meson: Move C99 test earlier
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
1 parent ba3d93b commit 4a40380

File tree

1 file changed

+42
-43
lines changed

1 file changed

+42
-43
lines changed

meson.build

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,48 @@ dir_doc_extension = dir_doc / 'extension'
550550
# used, they need to be added to test_c_args as well.
551551
###############################################################
552552

553+
# Do we need -std=c99 to compile C99 code? We don't want to add -std=c99
554+
# unnecessarily, because we optionally rely on newer features.
555+
c99_test = '''
556+
#include <stdbool.h>
557+
#include <complex.h>
558+
#include <tgmath.h>
559+
#include <inttypes.h>
560+
561+
struct named_init_test {
562+
int a;
563+
int b;
564+
};
565+
566+
extern void structfunc(struct named_init_test);
567+
568+
int main(int argc, char **argv)
569+
{
570+
struct named_init_test nit = {
571+
.a = 3,
572+
.b = 5,
573+
};
574+
575+
for (int loop_var = 0; loop_var < 3; loop_var++)
576+
{
577+
nit.a += nit.b;
578+
}
579+
580+
structfunc((struct named_init_test){1, 0});
581+
582+
return nit.a != 0;
583+
}
584+
'''
585+
586+
if not cc.compiles(c99_test, name: 'c99')
587+
if cc.compiles(c99_test, name: 'c99 with -std=c99', args: ['-std=c99'])
588+
cflags += '-std=c99'
589+
else
590+
error('C compiler does not support C99')
591+
endif
592+
endif
593+
594+
553595
postgres_inc = [include_directories(postgres_inc_d)]
554596
test_lib_d = postgres_lib_d
555597
test_c_args = cppflags + cflags
@@ -1704,49 +1746,6 @@ endif
17041746
# Compiler tests
17051747
###############################################################
17061748

1707-
# Do we need -std=c99 to compile C99 code? We don't want to add -std=c99
1708-
# unnecessarily, because we optionally rely on newer features.
1709-
c99_test = '''
1710-
#include <stdbool.h>
1711-
#include <complex.h>
1712-
#include <tgmath.h>
1713-
#include <inttypes.h>
1714-
1715-
struct named_init_test {
1716-
int a;
1717-
int b;
1718-
};
1719-
1720-
extern void structfunc(struct named_init_test);
1721-
1722-
int main(int argc, char **argv)
1723-
{
1724-
struct named_init_test nit = {
1725-
.a = 3,
1726-
.b = 5,
1727-
};
1728-
1729-
for (int loop_var = 0; loop_var < 3; loop_var++)
1730-
{
1731-
nit.a += nit.b;
1732-
}
1733-
1734-
structfunc((struct named_init_test){1, 0});
1735-
1736-
return nit.a != 0;
1737-
}
1738-
'''
1739-
1740-
if not cc.compiles(c99_test, name: 'c99', args: test_c_args)
1741-
if cc.compiles(c99_test, name: 'c99 with -std=c99',
1742-
args: test_c_args + ['-std=c99'])
1743-
test_c_args += '-std=c99'
1744-
cflags += '-std=c99'
1745-
else
1746-
error('C compiler does not support C99')
1747-
endif
1748-
endif
1749-
17501749
if host_machine.endian() == 'big'
17511750
cdata.set('WORDS_BIGENDIAN', 1)
17521751
endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy