ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there a compiler compatibility flag for C++ like -std=c99 ? Or is there some other way to get new g++ compilers to not choke on old code?
Yes, C++ compiler uses the same flag like the C compiler, so just use the -std= option with one of the following values:
c++98: The 1998 ISO C++ standard plus amendments. Same as -ansi for C++ code.
gnu++98: GNU dialect of -std=c++98. This is the default for C++ code.
c++0x: The working draft of the upcoming ISO C++0x standard. This option enables experimental features that are likely to be included in C++0x. The working draft is constantly changing, and any feature that is enabled by this flag may be removed from future versions of GCC if it is not part of the C++0x standard.
gnu++0x: GNU dialect of -std=c++0x. This option enables experimental features that may be removed in future versions of GCC.
Ah, thanks very much. I'm pretty sure I did try std=c++99 and got an error about unrecognized option, so I'll probably have to rebuild the compiler to enable the support for it.
Ah, thanks very much. I'm pretty sure I did try std=c++99 and got an error about unrecognized option, so I'll probably have to rebuild the compiler to enable the support for it.
Well, various. My main compiler right now is 4.4.2, but I have 4.3.2 and 4.2.1. When I have something really old to compile, I usually break down and use 3.4.6 which I have st up as an alternative compiler. 4.3.2 and 4.2.1 are both candidates for my main compiler -I have my own home-grown system so I can settle on any one of them in the end, thoguh 4.4.2 would be the best bet since I am using glibc-2.11.1. I pretty sure that gcc-4.3.2 supports the --enable-c99 configuration option, but do I need to pass --enable-c++99 as well?
Is using the -ansi compiler option comparable, or is that only for C?
Well, various. My main compiler right now is 4.4.2
Okay, 4.4.2 looks quite recent ;-)
Quote:
Originally Posted by gnashley
I pretty sure that gcc-4.3.2 supports the --enable-c99 configuration option, but do I need to pass --enable-c++99 as well?
I don't know about these options - which doesn't mean they don't exist - but I can't find any indications in 4.4.2 at least that the -std options depend on the configure input. As far as I know, the -std=* options should be valid for the default configuration of gcc/g++.
Quote:
Originally Posted by gnashley
Is using the -ansi compiler option comparable, or is that only for C?
Here's the comment from the man page:
-ansi: In C mode, this is equivalent to -std=c89. In C++ mode, it is equivalent to -std=c++98.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.