This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gcc/g++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]