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.
hi, what's the different between
gcc -std=c++98 and g++ ?
Files Test.cpp
Code:
#include <stdio.h>
int main(int argc, char *argv[]){
printf("Test");
}
I compiled with
g++ Test.cpp
it's fined
but when I compiled with
gcc -std=c++98 Test.cpp or gcc Test.cpp
it's error and print
[quote]
/tmp/ccmerMxh.o.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[/qoute]
In C mode, this is equivalent to -std=c89. 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.
The alternate keywords "__asm__", "__extension__", "__inline__" and "__typeof__" continue to work despite -ansi. You would not want to use them in an ISO C program, of course, but it is useful to put them in header files that might be included in compilations done with -ansi. Alternate predefined macros such as "__unix__" and "__vax__" are also available, with or without -ansi.
The -ansi option does not cause non-ISO programs to be rejected gratuitously. For that, -pedantic is required in addition to -ansi.
The macro "__STRICT_ANSI__" is predefined when the -ansi option is used. Some header files may notice this macro and refrain from declaring certain functions or defining certain macros that the ISO standard doesn’t call for; this is to avoid interfering with any programs that might use these names for other things.
Functions that would normally be built in but do not have semantics defined by ISO C (such as "alloca" and "ffs") are not built-in functions when -ansi is used.
Note that the error says ld returned 1 exit status, so it is not gcc that makes the error, but rather ld that does not find the reference to __gxx_personality_v0, at least that is how I understand it
A quick google search shows me that __gxx_personality_v0 is defined by the libstdc++.so library
Maybe this will work: gcc -std=c++98 -lstdc++ Test.cpp
This option is invalid for C as it is a C++ option, the option you want is quoted in matthewg42's post (-std=c89).
__gxx_personality_v0 is related to C++ exceptions and I would surmise the compiler is getting confused due to the file extension. Instead try compiling the code with "gcc -x c Test.cpp" which overrides the file extension.
Last edited by dmail; 09-14-2008 at 08:36 AM.
Reason: typo c89 not c98
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.