LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-18-2010, 08:59 AM   #1
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Equivalent of std=c99 for C++ ?


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?
 
Old 01-18-2010, 04:21 PM   #2
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by gnashley View Post
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.

- Andi -
 
Old 01-19-2010, 01:21 AM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Original Poster
Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
Old 01-19-2010, 09:39 AM   #4
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by gnashley View Post
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.
What version of gcc/g++ are you using? (gcc -v)

- Andi -
 
Old 01-19-2010, 11:00 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Original Poster
Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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?
 
Old 01-20-2010, 05:09 PM   #6
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by gnashley View Post
Well, various. My main compiler right now is 4.4.2
Okay, 4.4.2 looks quite recent ;-)

Quote:
Originally Posted by gnashley View Post
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 View Post
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.

- Andi -
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Use Type Identifiers as Function Parameters in C99? KareemSedki Programming 4 05-02-2008 11:45 AM
How to let MAKE invoke gcc with "-std=c99" cryincold Programming 16 03-10-2008 09:31 AM
Compiler issue c99 sgriffiths Linux - Software 9 11-29-2006 03:23 AM
what does the std:: do? RHLinuxGUY Programming 1 11-15-2005 01:01 PM
C99 libs in ISO C++ ta0kira Programming 0 05-20-2005 02:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration