Disabling C++11 in GCC 7.3
Clash Royale CLAN TAG#URR8PPP
up vote
11
down vote
favorite
It seems like in Ubuntu 18.04, the default shipped g++ (version 7.3.0) runs in C++11 compatible mode by default. I am getting some errors in my old codes which are not C++11 compatible. I installed g++-6 (version 6.4.0) and the programs are compiling fine. Is it possible to disable C++11 mode in g++-7?
gcc c++ g++
 |Â
show 5 more comments
up vote
11
down vote
favorite
It seems like in Ubuntu 18.04, the default shipped g++ (version 7.3.0) runs in C++11 compatible mode by default. I am getting some errors in my old codes which are not C++11 compatible. I installed g++-6 (version 6.4.0) and the programs are compiling fine. Is it possible to disable C++11 mode in g++-7?
gcc c++ g++
1
Actually, the default mode of GCC 6 is already C++14. GCC 7 adds C++17 support; it's probably sufficient to just disable this C++17 stuff. There's no need to go back to C++11. Going back to C++98 is really massive overkill (underkill?)
â MSalters
Aug 10 at 12:28
5
what did you do in old programs that aren't compatible? You might have been able to do things you weren't allowed to in the first place due to bugs. In which case you aren't going to gain anything from going to c++98.
â opa
Aug 10 at 13:49
9
@snb: Or they usedstd::auto_ptr
, or they usedauto
in its original guise, or they have now-illegal narrowing conversions, or they usedexport
, or, or, or
â Lightness Races in Orbit
Aug 10 at 14:12
1
@snb: stackoverflow.com/a/6402166/560648
â Lightness Races in Orbit
Aug 10 at 14:12
2
@LightnessRacesinOrbit Most of that would have been poor practice before C++11.
â opa
Aug 10 at 14:15
 |Â
show 5 more comments
up vote
11
down vote
favorite
up vote
11
down vote
favorite
It seems like in Ubuntu 18.04, the default shipped g++ (version 7.3.0) runs in C++11 compatible mode by default. I am getting some errors in my old codes which are not C++11 compatible. I installed g++-6 (version 6.4.0) and the programs are compiling fine. Is it possible to disable C++11 mode in g++-7?
gcc c++ g++
It seems like in Ubuntu 18.04, the default shipped g++ (version 7.3.0) runs in C++11 compatible mode by default. I am getting some errors in my old codes which are not C++11 compatible. I installed g++-6 (version 6.4.0) and the programs are compiling fine. Is it possible to disable C++11 mode in g++-7?
gcc c++ g++
edited Aug 11 at 16:46
Vadim Kotov
1278
1278
asked Aug 10 at 10:26
Soo
738
738
1
Actually, the default mode of GCC 6 is already C++14. GCC 7 adds C++17 support; it's probably sufficient to just disable this C++17 stuff. There's no need to go back to C++11. Going back to C++98 is really massive overkill (underkill?)
â MSalters
Aug 10 at 12:28
5
what did you do in old programs that aren't compatible? You might have been able to do things you weren't allowed to in the first place due to bugs. In which case you aren't going to gain anything from going to c++98.
â opa
Aug 10 at 13:49
9
@snb: Or they usedstd::auto_ptr
, or they usedauto
in its original guise, or they have now-illegal narrowing conversions, or they usedexport
, or, or, or
â Lightness Races in Orbit
Aug 10 at 14:12
1
@snb: stackoverflow.com/a/6402166/560648
â Lightness Races in Orbit
Aug 10 at 14:12
2
@LightnessRacesinOrbit Most of that would have been poor practice before C++11.
â opa
Aug 10 at 14:15
 |Â
show 5 more comments
1
Actually, the default mode of GCC 6 is already C++14. GCC 7 adds C++17 support; it's probably sufficient to just disable this C++17 stuff. There's no need to go back to C++11. Going back to C++98 is really massive overkill (underkill?)
â MSalters
Aug 10 at 12:28
5
what did you do in old programs that aren't compatible? You might have been able to do things you weren't allowed to in the first place due to bugs. In which case you aren't going to gain anything from going to c++98.
â opa
Aug 10 at 13:49
9
@snb: Or they usedstd::auto_ptr
, or they usedauto
in its original guise, or they have now-illegal narrowing conversions, or they usedexport
, or, or, or
â Lightness Races in Orbit
Aug 10 at 14:12
1
@snb: stackoverflow.com/a/6402166/560648
â Lightness Races in Orbit
Aug 10 at 14:12
2
@LightnessRacesinOrbit Most of that would have been poor practice before C++11.
â opa
Aug 10 at 14:15
1
1
Actually, the default mode of GCC 6 is already C++14. GCC 7 adds C++17 support; it's probably sufficient to just disable this C++17 stuff. There's no need to go back to C++11. Going back to C++98 is really massive overkill (underkill?)
â MSalters
Aug 10 at 12:28
Actually, the default mode of GCC 6 is already C++14. GCC 7 adds C++17 support; it's probably sufficient to just disable this C++17 stuff. There's no need to go back to C++11. Going back to C++98 is really massive overkill (underkill?)
â MSalters
Aug 10 at 12:28
5
5
what did you do in old programs that aren't compatible? You might have been able to do things you weren't allowed to in the first place due to bugs. In which case you aren't going to gain anything from going to c++98.
â opa
Aug 10 at 13:49
what did you do in old programs that aren't compatible? You might have been able to do things you weren't allowed to in the first place due to bugs. In which case you aren't going to gain anything from going to c++98.
â opa
Aug 10 at 13:49
9
9
@snb: Or they used
std::auto_ptr
, or they used auto
in its original guise, or they have now-illegal narrowing conversions, or they used export
, or, or, orâ Lightness Races in Orbit
Aug 10 at 14:12
@snb: Or they used
std::auto_ptr
, or they used auto
in its original guise, or they have now-illegal narrowing conversions, or they used export
, or, or, orâ Lightness Races in Orbit
Aug 10 at 14:12
1
1
@snb: stackoverflow.com/a/6402166/560648
â Lightness Races in Orbit
Aug 10 at 14:12
@snb: stackoverflow.com/a/6402166/560648
â Lightness Races in Orbit
Aug 10 at 14:12
2
2
@LightnessRacesinOrbit Most of that would have been poor practice before C++11.
â opa
Aug 10 at 14:15
@LightnessRacesinOrbit Most of that would have been poor practice before C++11.
â opa
Aug 10 at 14:15
 |Â
show 5 more comments
2 Answers
2
active
oldest
votes
up vote
20
down vote
accepted
Try adding -std=gnu++98
, it was probably the default for gcc 6.4.0.
Example:
g++ -std=gnu++98 hello.cpp -o hello
5
If you need ABI compatibility with code compiled by old GCCs, you'll want-D_GLIBCXX_USE_CXX11_ABI=0
as well
â Tavian Barnes
Aug 10 at 20:57
2
Or-std=gnu++03
for the last standard before C++11. Also worth mentioning that-std=c++03
will disable some GNU extensions that are incompatible with strict ISO C++.
â Peter Cordes
Aug 11 at 4:33
1
On the Godbolt compiler explorer, C++14 is the default for g++6.3 godbolt.org/g/x2xPCS. C++98 was the default for g++5.5 and older. I checked the value of__cplusplus
: How to determine the version of the C++ standard used by the compiler?
â Peter Cordes
Aug 11 at 4:35
add a comment |Â
up vote
1
down vote
From the man g++
you can select between different dialects:
Options Controlling C Dialect
The following options control the dialect of C (or languages derived
from C, such as C++, Objective-C and Objective-C++) that the compiler
accepts:
-ansi
In C mode, this is equivalent to -std=c90. In C++ mode, it is
equivalent to -std=c++98.
This turns off certain features of GCC that are incompatible with
ISO C90 (when compiling C code), or of standard C++ (when compiling
C++ code), such as the "asm" and "typeof" keywords, and predefined
macros such as "unix" and "vax" that identify the type of system
you are using. It also enables the undesirable and rarely used ISO
trigraph feature. For the C compiler, it disables recognition of
C++ style // comments as well as the "inline" keyword.
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
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 standard is specified, the compiler accepts
all programs following that standard plus those using GNU
extensions that do not contradict it. For 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 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
dialect of a standard is specified, all features supported by the
compiler are enabled, even when those features change the meaning
of the base standard. As a result, some strict-conforming programs
may be rejected. The particular standard is used by -Wpedantic to
identify which features are GNU extensions given that version of
the standard. For example -std=gnu90 -Wpedantic warns about C++
style // comments, while -std=gnu99 -Wpedantic does not.
A value for this option must be provided; possible values are
c90
c89
iso9899:1990
Support all ISO C90 programs (certain GNU extensions that
conflict with ISO C90 are disabled). Same as -ansi for C code.
iso9899:199409
ISO C90 as modified in amendment 1.
c99
c9x
iso9899:1999
iso9899:199x
ISO C99. This standard is substantially completely supported,
modulo bugs and floating-point issues (mainly but not entirely
relating to optional C99 features from Annexes F and G). See
<http://gcc.gnu.org/c99status.html> for more information. The
names c9x and iso9899:199x are deprecated.
c11
c1x
iso9899:2011
ISO C11, the 2011 revision of the ISO C standard. This
standard is substantially completely supported, modulo bugs,
floating-point issues (mainly but not entirely relating to
optional C11 features from Annexes F and G) and the optional
Annexes K (Bounds-checking interfaces) and L (Analyzability).
The name c1x is deprecated.
gnu90
gnu89
GNU dialect of ISO C90 (including some C99 features).
gnu99
gnu9x
GNU dialect of ISO C99. The name gnu9x is deprecated.
gnu11
gnu1x
GNU dialect of ISO C11. This is the default for C code. The
name gnu1x is deprecated.
c++98
c++03
The 1998 ISO C++ standard plus the 2003 technical corrigendum
and some additional defect reports. Same as -ansi for C++ code.
gnu++98
gnu++03
GNU dialect of -std=c++98.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
gnu++11
gnu++0x
GNU dialect of -std=c++11. The name gnu++0x is deprecated.
c++14
c++1y
The 2014 ISO C++ standard plus amendments. The name c++1y is
deprecated.
gnu++14
gnu++1y
GNU dialect of -std=c++14. This is the default for C++ code.
The name gnu++1y is deprecated.
c++1z
The next revision of the ISO C++ standard, tentatively planned
for 2017. Support is highly experimental, and will almost
certainly change in incompatible ways in future releases.
gnu++1z
GNU dialect of -std=c++1z. Support is highly experimental, and
will almost certainly change in incompatible ways in future
releases.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
20
down vote
accepted
Try adding -std=gnu++98
, it was probably the default for gcc 6.4.0.
Example:
g++ -std=gnu++98 hello.cpp -o hello
5
If you need ABI compatibility with code compiled by old GCCs, you'll want-D_GLIBCXX_USE_CXX11_ABI=0
as well
â Tavian Barnes
Aug 10 at 20:57
2
Or-std=gnu++03
for the last standard before C++11. Also worth mentioning that-std=c++03
will disable some GNU extensions that are incompatible with strict ISO C++.
â Peter Cordes
Aug 11 at 4:33
1
On the Godbolt compiler explorer, C++14 is the default for g++6.3 godbolt.org/g/x2xPCS. C++98 was the default for g++5.5 and older. I checked the value of__cplusplus
: How to determine the version of the C++ standard used by the compiler?
â Peter Cordes
Aug 11 at 4:35
add a comment |Â
up vote
20
down vote
accepted
Try adding -std=gnu++98
, it was probably the default for gcc 6.4.0.
Example:
g++ -std=gnu++98 hello.cpp -o hello
5
If you need ABI compatibility with code compiled by old GCCs, you'll want-D_GLIBCXX_USE_CXX11_ABI=0
as well
â Tavian Barnes
Aug 10 at 20:57
2
Or-std=gnu++03
for the last standard before C++11. Also worth mentioning that-std=c++03
will disable some GNU extensions that are incompatible with strict ISO C++.
â Peter Cordes
Aug 11 at 4:33
1
On the Godbolt compiler explorer, C++14 is the default for g++6.3 godbolt.org/g/x2xPCS. C++98 was the default for g++5.5 and older. I checked the value of__cplusplus
: How to determine the version of the C++ standard used by the compiler?
â Peter Cordes
Aug 11 at 4:35
add a comment |Â
up vote
20
down vote
accepted
up vote
20
down vote
accepted
Try adding -std=gnu++98
, it was probably the default for gcc 6.4.0.
Example:
g++ -std=gnu++98 hello.cpp -o hello
Try adding -std=gnu++98
, it was probably the default for gcc 6.4.0.
Example:
g++ -std=gnu++98 hello.cpp -o hello
edited Aug 10 at 10:53
answered Aug 10 at 10:48
pim
1,690722
1,690722
5
If you need ABI compatibility with code compiled by old GCCs, you'll want-D_GLIBCXX_USE_CXX11_ABI=0
as well
â Tavian Barnes
Aug 10 at 20:57
2
Or-std=gnu++03
for the last standard before C++11. Also worth mentioning that-std=c++03
will disable some GNU extensions that are incompatible with strict ISO C++.
â Peter Cordes
Aug 11 at 4:33
1
On the Godbolt compiler explorer, C++14 is the default for g++6.3 godbolt.org/g/x2xPCS. C++98 was the default for g++5.5 and older. I checked the value of__cplusplus
: How to determine the version of the C++ standard used by the compiler?
â Peter Cordes
Aug 11 at 4:35
add a comment |Â
5
If you need ABI compatibility with code compiled by old GCCs, you'll want-D_GLIBCXX_USE_CXX11_ABI=0
as well
â Tavian Barnes
Aug 10 at 20:57
2
Or-std=gnu++03
for the last standard before C++11. Also worth mentioning that-std=c++03
will disable some GNU extensions that are incompatible with strict ISO C++.
â Peter Cordes
Aug 11 at 4:33
1
On the Godbolt compiler explorer, C++14 is the default for g++6.3 godbolt.org/g/x2xPCS. C++98 was the default for g++5.5 and older. I checked the value of__cplusplus
: How to determine the version of the C++ standard used by the compiler?
â Peter Cordes
Aug 11 at 4:35
5
5
If you need ABI compatibility with code compiled by old GCCs, you'll want
-D_GLIBCXX_USE_CXX11_ABI=0
as wellâ Tavian Barnes
Aug 10 at 20:57
If you need ABI compatibility with code compiled by old GCCs, you'll want
-D_GLIBCXX_USE_CXX11_ABI=0
as wellâ Tavian Barnes
Aug 10 at 20:57
2
2
Or
-std=gnu++03
for the last standard before C++11. Also worth mentioning that -std=c++03
will disable some GNU extensions that are incompatible with strict ISO C++.â Peter Cordes
Aug 11 at 4:33
Or
-std=gnu++03
for the last standard before C++11. Also worth mentioning that -std=c++03
will disable some GNU extensions that are incompatible with strict ISO C++.â Peter Cordes
Aug 11 at 4:33
1
1
On the Godbolt compiler explorer, C++14 is the default for g++6.3 godbolt.org/g/x2xPCS. C++98 was the default for g++5.5 and older. I checked the value of
__cplusplus
: How to determine the version of the C++ standard used by the compiler?â Peter Cordes
Aug 11 at 4:35
On the Godbolt compiler explorer, C++14 is the default for g++6.3 godbolt.org/g/x2xPCS. C++98 was the default for g++5.5 and older. I checked the value of
__cplusplus
: How to determine the version of the C++ standard used by the compiler?â Peter Cordes
Aug 11 at 4:35
add a comment |Â
up vote
1
down vote
From the man g++
you can select between different dialects:
Options Controlling C Dialect
The following options control the dialect of C (or languages derived
from C, such as C++, Objective-C and Objective-C++) that the compiler
accepts:
-ansi
In C mode, this is equivalent to -std=c90. In C++ mode, it is
equivalent to -std=c++98.
This turns off certain features of GCC that are incompatible with
ISO C90 (when compiling C code), or of standard C++ (when compiling
C++ code), such as the "asm" and "typeof" keywords, and predefined
macros such as "unix" and "vax" that identify the type of system
you are using. It also enables the undesirable and rarely used ISO
trigraph feature. For the C compiler, it disables recognition of
C++ style // comments as well as the "inline" keyword.
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
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 standard is specified, the compiler accepts
all programs following that standard plus those using GNU
extensions that do not contradict it. For 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 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
dialect of a standard is specified, all features supported by the
compiler are enabled, even when those features change the meaning
of the base standard. As a result, some strict-conforming programs
may be rejected. The particular standard is used by -Wpedantic to
identify which features are GNU extensions given that version of
the standard. For example -std=gnu90 -Wpedantic warns about C++
style // comments, while -std=gnu99 -Wpedantic does not.
A value for this option must be provided; possible values are
c90
c89
iso9899:1990
Support all ISO C90 programs (certain GNU extensions that
conflict with ISO C90 are disabled). Same as -ansi for C code.
iso9899:199409
ISO C90 as modified in amendment 1.
c99
c9x
iso9899:1999
iso9899:199x
ISO C99. This standard is substantially completely supported,
modulo bugs and floating-point issues (mainly but not entirely
relating to optional C99 features from Annexes F and G). See
<http://gcc.gnu.org/c99status.html> for more information. The
names c9x and iso9899:199x are deprecated.
c11
c1x
iso9899:2011
ISO C11, the 2011 revision of the ISO C standard. This
standard is substantially completely supported, modulo bugs,
floating-point issues (mainly but not entirely relating to
optional C11 features from Annexes F and G) and the optional
Annexes K (Bounds-checking interfaces) and L (Analyzability).
The name c1x is deprecated.
gnu90
gnu89
GNU dialect of ISO C90 (including some C99 features).
gnu99
gnu9x
GNU dialect of ISO C99. The name gnu9x is deprecated.
gnu11
gnu1x
GNU dialect of ISO C11. This is the default for C code. The
name gnu1x is deprecated.
c++98
c++03
The 1998 ISO C++ standard plus the 2003 technical corrigendum
and some additional defect reports. Same as -ansi for C++ code.
gnu++98
gnu++03
GNU dialect of -std=c++98.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
gnu++11
gnu++0x
GNU dialect of -std=c++11. The name gnu++0x is deprecated.
c++14
c++1y
The 2014 ISO C++ standard plus amendments. The name c++1y is
deprecated.
gnu++14
gnu++1y
GNU dialect of -std=c++14. This is the default for C++ code.
The name gnu++1y is deprecated.
c++1z
The next revision of the ISO C++ standard, tentatively planned
for 2017. Support is highly experimental, and will almost
certainly change in incompatible ways in future releases.
gnu++1z
GNU dialect of -std=c++1z. Support is highly experimental, and
will almost certainly change in incompatible ways in future
releases.
add a comment |Â
up vote
1
down vote
From the man g++
you can select between different dialects:
Options Controlling C Dialect
The following options control the dialect of C (or languages derived
from C, such as C++, Objective-C and Objective-C++) that the compiler
accepts:
-ansi
In C mode, this is equivalent to -std=c90. In C++ mode, it is
equivalent to -std=c++98.
This turns off certain features of GCC that are incompatible with
ISO C90 (when compiling C code), or of standard C++ (when compiling
C++ code), such as the "asm" and "typeof" keywords, and predefined
macros such as "unix" and "vax" that identify the type of system
you are using. It also enables the undesirable and rarely used ISO
trigraph feature. For the C compiler, it disables recognition of
C++ style // comments as well as the "inline" keyword.
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
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 standard is specified, the compiler accepts
all programs following that standard plus those using GNU
extensions that do not contradict it. For 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 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
dialect of a standard is specified, all features supported by the
compiler are enabled, even when those features change the meaning
of the base standard. As a result, some strict-conforming programs
may be rejected. The particular standard is used by -Wpedantic to
identify which features are GNU extensions given that version of
the standard. For example -std=gnu90 -Wpedantic warns about C++
style // comments, while -std=gnu99 -Wpedantic does not.
A value for this option must be provided; possible values are
c90
c89
iso9899:1990
Support all ISO C90 programs (certain GNU extensions that
conflict with ISO C90 are disabled). Same as -ansi for C code.
iso9899:199409
ISO C90 as modified in amendment 1.
c99
c9x
iso9899:1999
iso9899:199x
ISO C99. This standard is substantially completely supported,
modulo bugs and floating-point issues (mainly but not entirely
relating to optional C99 features from Annexes F and G). See
<http://gcc.gnu.org/c99status.html> for more information. The
names c9x and iso9899:199x are deprecated.
c11
c1x
iso9899:2011
ISO C11, the 2011 revision of the ISO C standard. This
standard is substantially completely supported, modulo bugs,
floating-point issues (mainly but not entirely relating to
optional C11 features from Annexes F and G) and the optional
Annexes K (Bounds-checking interfaces) and L (Analyzability).
The name c1x is deprecated.
gnu90
gnu89
GNU dialect of ISO C90 (including some C99 features).
gnu99
gnu9x
GNU dialect of ISO C99. The name gnu9x is deprecated.
gnu11
gnu1x
GNU dialect of ISO C11. This is the default for C code. The
name gnu1x is deprecated.
c++98
c++03
The 1998 ISO C++ standard plus the 2003 technical corrigendum
and some additional defect reports. Same as -ansi for C++ code.
gnu++98
gnu++03
GNU dialect of -std=c++98.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
gnu++11
gnu++0x
GNU dialect of -std=c++11. The name gnu++0x is deprecated.
c++14
c++1y
The 2014 ISO C++ standard plus amendments. The name c++1y is
deprecated.
gnu++14
gnu++1y
GNU dialect of -std=c++14. This is the default for C++ code.
The name gnu++1y is deprecated.
c++1z
The next revision of the ISO C++ standard, tentatively planned
for 2017. Support is highly experimental, and will almost
certainly change in incompatible ways in future releases.
gnu++1z
GNU dialect of -std=c++1z. Support is highly experimental, and
will almost certainly change in incompatible ways in future
releases.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
From the man g++
you can select between different dialects:
Options Controlling C Dialect
The following options control the dialect of C (or languages derived
from C, such as C++, Objective-C and Objective-C++) that the compiler
accepts:
-ansi
In C mode, this is equivalent to -std=c90. In C++ mode, it is
equivalent to -std=c++98.
This turns off certain features of GCC that are incompatible with
ISO C90 (when compiling C code), or of standard C++ (when compiling
C++ code), such as the "asm" and "typeof" keywords, and predefined
macros such as "unix" and "vax" that identify the type of system
you are using. It also enables the undesirable and rarely used ISO
trigraph feature. For the C compiler, it disables recognition of
C++ style // comments as well as the "inline" keyword.
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
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 standard is specified, the compiler accepts
all programs following that standard plus those using GNU
extensions that do not contradict it. For 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 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
dialect of a standard is specified, all features supported by the
compiler are enabled, even when those features change the meaning
of the base standard. As a result, some strict-conforming programs
may be rejected. The particular standard is used by -Wpedantic to
identify which features are GNU extensions given that version of
the standard. For example -std=gnu90 -Wpedantic warns about C++
style // comments, while -std=gnu99 -Wpedantic does not.
A value for this option must be provided; possible values are
c90
c89
iso9899:1990
Support all ISO C90 programs (certain GNU extensions that
conflict with ISO C90 are disabled). Same as -ansi for C code.
iso9899:199409
ISO C90 as modified in amendment 1.
c99
c9x
iso9899:1999
iso9899:199x
ISO C99. This standard is substantially completely supported,
modulo bugs and floating-point issues (mainly but not entirely
relating to optional C99 features from Annexes F and G). See
<http://gcc.gnu.org/c99status.html> for more information. The
names c9x and iso9899:199x are deprecated.
c11
c1x
iso9899:2011
ISO C11, the 2011 revision of the ISO C standard. This
standard is substantially completely supported, modulo bugs,
floating-point issues (mainly but not entirely relating to
optional C11 features from Annexes F and G) and the optional
Annexes K (Bounds-checking interfaces) and L (Analyzability).
The name c1x is deprecated.
gnu90
gnu89
GNU dialect of ISO C90 (including some C99 features).
gnu99
gnu9x
GNU dialect of ISO C99. The name gnu9x is deprecated.
gnu11
gnu1x
GNU dialect of ISO C11. This is the default for C code. The
name gnu1x is deprecated.
c++98
c++03
The 1998 ISO C++ standard plus the 2003 technical corrigendum
and some additional defect reports. Same as -ansi for C++ code.
gnu++98
gnu++03
GNU dialect of -std=c++98.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
gnu++11
gnu++0x
GNU dialect of -std=c++11. The name gnu++0x is deprecated.
c++14
c++1y
The 2014 ISO C++ standard plus amendments. The name c++1y is
deprecated.
gnu++14
gnu++1y
GNU dialect of -std=c++14. This is the default for C++ code.
The name gnu++1y is deprecated.
c++1z
The next revision of the ISO C++ standard, tentatively planned
for 2017. Support is highly experimental, and will almost
certainly change in incompatible ways in future releases.
gnu++1z
GNU dialect of -std=c++1z. Support is highly experimental, and
will almost certainly change in incompatible ways in future
releases.
From the man g++
you can select between different dialects:
Options Controlling C Dialect
The following options control the dialect of C (or languages derived
from C, such as C++, Objective-C and Objective-C++) that the compiler
accepts:
-ansi
In C mode, this is equivalent to -std=c90. In C++ mode, it is
equivalent to -std=c++98.
This turns off certain features of GCC that are incompatible with
ISO C90 (when compiling C code), or of standard C++ (when compiling
C++ code), such as the "asm" and "typeof" keywords, and predefined
macros such as "unix" and "vax" that identify the type of system
you are using. It also enables the undesirable and rarely used ISO
trigraph feature. For the C compiler, it disables recognition of
C++ style // comments as well as the "inline" keyword.
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
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 standard is specified, the compiler accepts
all programs following that standard plus those using GNU
extensions that do not contradict it. For 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 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
dialect of a standard is specified, all features supported by the
compiler are enabled, even when those features change the meaning
of the base standard. As a result, some strict-conforming programs
may be rejected. The particular standard is used by -Wpedantic to
identify which features are GNU extensions given that version of
the standard. For example -std=gnu90 -Wpedantic warns about C++
style // comments, while -std=gnu99 -Wpedantic does not.
A value for this option must be provided; possible values are
c90
c89
iso9899:1990
Support all ISO C90 programs (certain GNU extensions that
conflict with ISO C90 are disabled). Same as -ansi for C code.
iso9899:199409
ISO C90 as modified in amendment 1.
c99
c9x
iso9899:1999
iso9899:199x
ISO C99. This standard is substantially completely supported,
modulo bugs and floating-point issues (mainly but not entirely
relating to optional C99 features from Annexes F and G). See
<http://gcc.gnu.org/c99status.html> for more information. The
names c9x and iso9899:199x are deprecated.
c11
c1x
iso9899:2011
ISO C11, the 2011 revision of the ISO C standard. This
standard is substantially completely supported, modulo bugs,
floating-point issues (mainly but not entirely relating to
optional C11 features from Annexes F and G) and the optional
Annexes K (Bounds-checking interfaces) and L (Analyzability).
The name c1x is deprecated.
gnu90
gnu89
GNU dialect of ISO C90 (including some C99 features).
gnu99
gnu9x
GNU dialect of ISO C99. The name gnu9x is deprecated.
gnu11
gnu1x
GNU dialect of ISO C11. This is the default for C code. The
name gnu1x is deprecated.
c++98
c++03
The 1998 ISO C++ standard plus the 2003 technical corrigendum
and some additional defect reports. Same as -ansi for C++ code.
gnu++98
gnu++03
GNU dialect of -std=c++98.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
gnu++11
gnu++0x
GNU dialect of -std=c++11. The name gnu++0x is deprecated.
c++14
c++1y
The 2014 ISO C++ standard plus amendments. The name c++1y is
deprecated.
gnu++14
gnu++1y
GNU dialect of -std=c++14. This is the default for C++ code.
The name gnu++1y is deprecated.
c++1z
The next revision of the ISO C++ standard, tentatively planned
for 2017. Support is highly experimental, and will almost
certainly change in incompatible ways in future releases.
gnu++1z
GNU dialect of -std=c++1z. Support is highly experimental, and
will almost certainly change in incompatible ways in future
releases.
answered Aug 30 at 15:14
abu_bua
2,1102721
2,1102721
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1064113%2fdisabling-c11-in-gcc-7-3%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Actually, the default mode of GCC 6 is already C++14. GCC 7 adds C++17 support; it's probably sufficient to just disable this C++17 stuff. There's no need to go back to C++11. Going back to C++98 is really massive overkill (underkill?)
â MSalters
Aug 10 at 12:28
5
what did you do in old programs that aren't compatible? You might have been able to do things you weren't allowed to in the first place due to bugs. In which case you aren't going to gain anything from going to c++98.
â opa
Aug 10 at 13:49
9
@snb: Or they used
std::auto_ptr
, or they usedauto
in its original guise, or they have now-illegal narrowing conversions, or they usedexport
, or, or, orâ Lightness Races in Orbit
Aug 10 at 14:12
1
@snb: stackoverflow.com/a/6402166/560648
â Lightness Races in Orbit
Aug 10 at 14:12
2
@LightnessRacesinOrbit Most of that would have been poor practice before C++11.
â opa
Aug 10 at 14:15