Skip to content

Commit dc6262e

Browse files
authored
Merge pull request #972 from OceanParcels/gcc_c-version_compileflag
Fixing gcc C-standard to prevent compile failure with newer compiler versions
2 parents 393d432 + 1fae16a commit dc6262e

3 files changed

Lines changed: 189 additions & 2 deletions

File tree

docs/c_standard_gcc7.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
-std=
2+
Determine the language standard. This option is currently only supported when compiling C or C++.
3+
4+
The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those standards, such as gnu90 or gnu++98. When a base
5+
standard is specified, the compiler accepts all programs following that standard plus those using GNU extensions that do not contradict it. For
6+
example, -std=c90 turns off certain features of GCC that are incompatible with ISO C90, such as the "asm" and "typeof" keywords, but not other
7+
GNU extensions that do not have a meaning in ISO C90, such as omitting the middle term of a "?:" expression. On the other hand, when a GNU
8+
dialect of a standard is specified, all features supported by the compiler are enabled, even when those features change the meaning of the base
9+
standard. As a result, some strict-conforming programs may be rejected. The particular standard is used by -Wpedantic to identify which
10+
features are GNU extensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about C++ style // comments, while
11+
-std=gnu99 -Wpedantic does not.
12+
13+
A value for this option must be provided; possible values are
14+
15+
c90
16+
c89
17+
iso9899:1990
18+
Support all ISO C90 programs (certain GNU extensions that conflict with ISO C90 are disabled). Same as -ansi for C code.
19+
20+
iso9899:199409
21+
ISO C90 as modified in amendment 1.
22+
23+
c99
24+
c9x
25+
iso9899:1999
26+
iso9899:199x
27+
ISO C99. This standard is substantially completely supported, modulo bugs and floating-point issues (mainly but not entirely relating to
28+
optional C99 features from Annexes F and G). See <http://gcc.gnu.org/c99status.html> for more information. The names c9x and iso9899:199x
29+
are deprecated.
30+
31+
c11
32+
c1x
33+
iso9899:2011
34+
ISO C11, the 2011 revision of the ISO C standard. This standard is substantially completely supported, modulo bugs, floating-point issues
35+
(mainly but not entirely relating to optional C11 features from Annexes F and G) and the optional Annexes K (Bounds-checking interfaces) and
36+
L (Analyzability). The name c1x is deprecated.
37+
38+
gnu90
39+
gnu89
40+
GNU dialect of ISO C90 (including some C99 features).
41+
42+
gnu99
43+
gnu9x
44+
GNU dialect of ISO C99. The name gnu9x is deprecated.
45+
46+
gnu11
47+
gnu1x
48+
GNU dialect of ISO C11. This is the default for C code. The name gnu1x is deprecated.
49+
50+
c++98
51+
c++03
52+
The 1998 ISO C++ standard plus the 2003 technical corrigendum and some additional defect reports. Same as -ansi for C++ code.
53+
54+
gnu++98
55+
gnu++03
56+
GNU dialect of -std=c++98.
57+
58+
c++11
59+
c++0x
60+
The 2011 ISO C++ standard plus amendments. The name c++0x is deprecated.
61+
62+
gnu++11
63+
gnu++0x
64+
GNU dialect of -std=c++11. The name gnu++0x is deprecated.
65+
66+
c++14
67+
c++1y
68+
The 2014 ISO C++ standard plus amendments. The name c++1y is deprecated.
69+
70+
gnu++14
71+
gnu++1y
72+
GNU dialect of -std=c++14. This is the default for C++ code. The name gnu++1y is deprecated.
73+
74+
c++1z
75+
The next revision of the ISO C++ standard, tentatively planned for 2017. Support is highly experimental, and will almost certainly change in
76+
incompatible ways in future releases.
77+
78+
gnu++1z
79+
GNU dialect of -std=c++1z. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.
80+

docs/c_standard_gcc8.txt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
-std=
2+
Determine the language standard. This option is currently only supported when compiling C or C++.
3+
4+
The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those standards, such as gnu90 or gnu++98. When a base
5+
standard is specified, the compiler accepts all programs following that standard plus those using GNU extensions that do not contradict it. For
6+
example, -std=c90 turns off certain features of GCC that are incompatible with ISO C90, such as the "asm" and "typeof" keywords, but not other
7+
GNU extensions that do not have a meaning in ISO C90, such as omitting the middle term of a "?:" expression. On the other hand, when a GNU
8+
dialect of a standard is specified, all features supported by the compiler are enabled, even when those features change the meaning of the base
9+
standard. As a result, some strict-conforming programs may be rejected. The particular standard is used by -Wpedantic to identify which
10+
features are GNU extensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about C++ style // comments, while
11+
-std=gnu99 -Wpedantic does not.
12+
13+
A value for this option must be provided; possible values are
14+
15+
c90
16+
c89
17+
iso9899:1990
18+
Support all ISO C90 programs (certain GNU extensions that conflict with ISO C90 are disabled). Same as -ansi for C code.
19+
20+
iso9899:199409
21+
ISO C90 as modified in amendment 1.
22+
23+
c99
24+
c9x
25+
iso9899:1999
26+
iso9899:199x
27+
ISO C99. This standard is substantially completely supported, modulo bugs and floating-point issues (mainly but not entirely relating to
28+
optional C99 features from Annexes F and G). See <http://gcc.gnu.org/c99status.html> for more information. The names c9x and iso9899:199x
29+
are deprecated.
30+
31+
c11
32+
c1x
33+
iso9899:2011
34+
ISO C11, the 2011 revision of the ISO C standard. This standard is substantially completely supported, modulo bugs, floating-point issues
35+
(mainly but not entirely relating to optional C11 features from Annexes F and G) and the optional Annexes K (Bounds-checking interfaces) and
36+
L (Analyzability). The name c1x is deprecated.
37+
38+
c17
39+
c18
40+
iso9899:2017
41+
iso9899:2018
42+
ISO C17, the 2017 revision of the ISO C standard (expected to be published in 2018). This standard is same as C11 except for corrections of
43+
defects (all of which are also applied with -std=c11) and a new value of "__STDC_VERSION__", and so is supported to the same extent as C11.
44+
45+
gnu90
46+
gnu89
47+
GNU dialect of ISO C90 (including some C99 features).
48+
49+
gnu99
50+
gnu9x
51+
GNU dialect of ISO C99. The name gnu9x is deprecated.
52+
53+
gnu11
54+
gnu1x
55+
GNU dialect of ISO C11. The name gnu1x is deprecated.
56+
57+
gnu17
58+
gnu18
59+
GNU dialect of ISO C17. This is the default for C code.
60+
61+
c++98
62+
c++03
63+
The 1998 ISO C++ standard plus the 2003 technical corrigendum and some additional defect reports. Same as -ansi for C++ code.
64+
65+
gnu++98
66+
gnu++03
67+
GNU dialect of -std=c++98.
68+
69+
c++11
70+
c++0x
71+
The 2011 ISO C++ standard plus amendments. The name c++0x is deprecated.
72+
73+
gnu++11
74+
gnu++0x
75+
GNU dialect of -std=c++11. The name gnu++0x is deprecated.
76+
77+
c++14
78+
c++1y
79+
The 2014 ISO C++ standard plus amendments. The name c++1y is deprecated.
80+
81+
gnu++14
82+
gnu++1y
83+
GNU dialect of -std=c++14. This is the default for C++ code. The name gnu++1y is deprecated.
84+
85+
c++17
86+
c++1z
87+
The 2017 ISO C++ standard plus amendments. The name c++1z is deprecated.
88+
gnu++17
89+
gnu++1z
90+
GNU dialect of -std=c++17. The name gnu++1z is deprecated.
91+
92+
c++2a
93+
The next revision of the ISO C++ standard, tentatively planned for 2020. Support is highly experimental, and will almost certainly change in
94+
incompatible ways in future releases.
95+
96+
gnu++2a
97+
GNU dialect of -std=c++2a. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.
98+
99+

parcels/compilation/codecompiler.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def __init__(self, cppargs=None, ldargs=None, incdirs=None, libdirs=None, libs=N
7575
libdirs = []
7676
if libs is None:
7777
libs = []
78+
libs.append("m")
7879

7980
Iflags = []
8081
if isinstance(incdirs, list):
@@ -90,10 +91,17 @@ def __init__(self, cppargs=None, ldargs=None, incdirs=None, libdirs=None, libs=N
9091
lflags.append("-l" + lib)
9192

9293
cc_env = os.getenv('CC')
93-
self._compiler = "mpicc" if MPI else "gcc" if cc_env is None else cc_env
94+
mpicc = None
95+
if MPI:
96+
mpicc_env = os.getenv('MPICC')
97+
mpicc = mpicc_env
98+
mpicc = "mpicc" if mpicc is None and os._exists("mpicc") else None
99+
mpicc = "mpiCC" if mpicc is None and os._exists("mpiCC") else None
100+
os.system("%s --version" % (mpicc))
101+
self._compiler = mpicc if MPI and mpicc is not None else cc_env if cc_env is not None else "gcc"
94102
opt_flags = ['-g', '-O3']
95103
arch_flag = ['-m64' if calcsize("P") == 8 else '-m32']
96-
self._cppargs = ['-Wall', '-fPIC']
104+
self._cppargs = ['-Wall', '-fPIC', '-std=gnu11']
97105
self._cppargs += Iflags
98106
self._cppargs += opt_flags + cppargs + arch_flag
99107
self._ldargs = ['-shared']

0 commit comments

Comments
 (0)