Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-14-2008, 05:52 AM   #1
Jacky Quah
LQ Newbie
Registered: May 2005
Posts: 28

Rep: Reputation: 15
What's the different between gcc and g++ ?

hi, what's the different between
gcc -std=c++98 and g++ ?

Files Test.cpp
#include <stdio.h>

int main(int argc, char *argv[]){
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
/tmp/ccmerMxh.o.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

why is that ?
Old 09-14-2008, 06:33 AM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
From the gcc manual page:
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.
Old 09-14-2008, 07:05 AM   #3
Jacky Quah
LQ Newbie
Registered: May 2005
Posts: 28

Original Poster
Rep: Reputation: 15
That's still doesn't answer my question.

I mean what's the different between :
g++ and gcc -std=c++98

when I compile with the code of my first post.
g++ compiled fine.
gcc -std=c++98
produce error as I stated before.

why is it like that ?
the code is standard C, if I am not wrong.

I want to try to compile if standard c library is work in c++ (g++ and gcc -std=c++98).

it worked in g++ but why it didn't work on gcc -std=c++98 ?

Last edited by Jacky Quah; 09-14-2008 at 07:09 AM.
Old 09-14-2008, 07:49 AM   #4
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,393

Rep: Reputation: 409Reputation: 409Reputation: 409Reputation: 409Reputation: 409
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 library

Maybe this will work: gcc -std=c++98 -lstdc++ Test.cpp
Old 09-14-2008, 07:52 AM   #5
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
gcc -std=c++98
produce error as I stated before.
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 09:36 AM. Reason: typo c89 not c98


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
equivalent of conio.h in gcc? (and some more gcc-newbie questions) Valkyrie_of_valhalla Programming 3 09-22-2007 04:32 AM
Assigning a short to a double. Differences between gcc-2.95 and gcc-3.4.x _john_i_ Programming 2 01-12-2007 02:11 PM
have gcc compilation error during gcc installtion in linuxfromscratch vbshanmugaprakash Linux - General 3 12-13-2006 06:52 AM
gcc wont install, 'failed dependencies: glibc-devel is needed by gcc-3.3.3-41' TdlSnare SUSE / openSUSE 3 11-29-2004 03:13 PM
export CC=/usr/bin/gcc-3.2 - switch gcc version? ferreter Linux - Software 1 08-20-2003 01:07 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:18 AM.

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