LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-14-2008, 04: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
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]

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

Rep: Reputation: 65
From the gcc manual page:
Quote:
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, 06: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.
but
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 06:09 AM.
 
Old 09-14-2008, 06:49 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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
 
Old 09-14-2008, 06:52 AM   #5
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Quote:
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 08:36 AM. Reason: typo c89 not c98
 
  


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

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

All times are GMT -5. The time now is 08:30 AM.

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