public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Gcc/g++
@ 2005-07-14  8:59 Sampath Kumar Herga
  2005-07-14 13:30 ` Gcc/g++ Ishwar Rattan
  0 siblings, 1 reply; 5+ messages in thread
From: Sampath Kumar Herga @ 2005-07-14  8:59 UTC (permalink / raw)
  To: random; +Cc: gcc-help

Chris,

Thanks for the response. Any specific reason to not use gcc to compile
g++ files? One thing I found was that when creating the final binary,
g++ needs to be used. Else it does not link in the correct libraries.
But for just generating .o from a .cpp file, does the use of gcc/g++
make any difference. 

Sampath. 

-----Original Message-----
From: random@bubblescope.net [mailto:random@bubblescope.net] 
Sent: Wednesday, July 13, 2005 9:21 PM
To: Sampath Kumar Herga
Cc: gcc-help@gcc.gnu.org
Subject: Re: Gcc/g++

Sampath Kumar Herga wrote:

> Hi,
>
>I am new to this group and had a very basic question. What is the 
>difference between gcc and g++ when compiling c++ files.
>
Short version: Don't use gcc to compile c++ files unless you know what
you are doing :)

>Also if we have
>a mix of c and c++ files in a project, which is the better compiler to 
>use?
>
>  
>
If you C files are also valid C++ (which there is a good chance there
will be, espically if they are well written), it would be easiest to
compile them all as C++. If you can't / don't want to do this, you'll
have to use the "extern C" notation to mark any functions called from,
or defined in, a C file.

>Please let me know if this is not the correct mailing-list for this 
>question.
>
>  
>
I'm fairly sure it is :)
Chris

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Gcc/g++
  2005-07-14  8:59 Gcc/g++ Sampath Kumar Herga
@ 2005-07-14 13:30 ` Ishwar Rattan
  0 siblings, 0 replies; 5+ messages in thread
From: Ishwar Rattan @ 2005-07-14 13:30 UTC (permalink / raw)
  To: gcc-help



On Thu, 14 Jul 2005, Sampath Kumar Herga wrote:

> Chris,
>
> Thanks for the response. Any specific reason to not use gcc to compile
> g++ files? One thing I found was that when creating the final binary,
> g++ needs to be used. Else it does not link in the correct libraries.

Gcc does not know about libstdc++ and has to be told.

-ishwar

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Gcc/g++
@ 2005-07-13 16:26 Eljay Love-Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Eljay Love-Jensen @ 2005-07-13 16:26 UTC (permalink / raw)
  To: Sampath Kumar Herga, gcc-help

Hi Sampath,

>What is the difference between gcc and g++ when compiling c++ files.

gcc is the tool-chain driver for compiling C files.

g++ is the tool-chain driver for compiling C++ files.

You can use the '-v' flag to enable verbose mode, which will give you more details what's going on behind the scenes.

The details do differ from OS to OS, and from GCC version to GCC version.  So I can't be more specific than that given the information you've provided.

>Also if we have a mix of c and c++ files in a project, which is the better compiler to use?

In general, I suggest making your C files C++ files with the minimal amount of work possible.  That "minimal amount of work" often is "no work whatsoever" or "merely renaming Foo.c to Foo.cpp", since C++ is a mostly compatible superset of C.

That's not always easily possible, though.  Ergo...

If you prefer to keep your C files as C files (i.e., C ABI for the object code), then you'll have to do a bit of work to make the C header files properly digestable in C++ land.  Annotating the globally linked identifiers with extern "C".  Making sure you never throw an exception over the C barrier.  Yada yada yada.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Gcc/g++
  2005-07-13 15:48 Gcc/g++ Sampath Kumar Herga
@ 2005-07-13 15:53 ` random
  0 siblings, 0 replies; 5+ messages in thread
From: random @ 2005-07-13 15:53 UTC (permalink / raw)
  To: Sampath Kumar Herga; +Cc: gcc-help

Sampath Kumar Herga wrote:

> Hi,
>
>I am new to this group and had a very basic question. What is the
>difference between gcc and g++ when compiling c++ files. 
>
Short version: Don't use gcc to compile c++ files unless you know what
you are doing :)

>Also if we have
>a mix of c and c++ files in a project, which is the better compiler to
>use?
>
>  
>
If you C files are also valid C++ (which there is a good chance there
will be, espically if they are well written), it would be easiest to
compile them all as C++. If you can't / don't want to do this, you'll
have to use the "extern C" notation to mark any functions called from,
or defined in, a C file.

>Please let me know if this is not the correct mailing-list for this
>question.
>
>  
>
I'm fairly sure it is :)
Chris

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Gcc/g++
@ 2005-07-13 15:48 Sampath Kumar Herga
  2005-07-13 15:53 ` Gcc/g++ random
  0 siblings, 1 reply; 5+ messages in thread
From: Sampath Kumar Herga @ 2005-07-13 15:48 UTC (permalink / raw)
  To: gcc-help

 Hi,

I am new to this group and had a very basic question. What is the
difference between gcc and g++ when compiling c++ files. Also if we have
a mix of c and c++ files in a project, which is the better compiler to
use?

Please let me know if this is not the correct mailing-list for this
question.

Thanks,
Sampath.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-07-14 13:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-14  8:59 Gcc/g++ Sampath Kumar Herga
2005-07-14 13:30 ` Gcc/g++ Ishwar Rattan
  -- strict thread matches above, loose matches on Subject: below --
2005-07-13 16:26 Gcc/g++ Eljay Love-Jensen
2005-07-13 15:48 Gcc/g++ Sampath Kumar Herga
2005-07-13 15:53 ` Gcc/g++ random

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).