Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Little bit of clearity about cc and gcc (Lesson26, Linux port)

This topic is 5296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I don''t understand why "most people who do serious C++ coding use GCC not G++" (because gcc automatically detect type of source by extension and use appropriate compiler). If you want to make a Makefile more crossplatform it''s better IMHO not to use CC=gcc. If you want to compile C code - use "cc" (Which is stands for "C compiler"), if you want to compile C++ code - use "c++". Lesson26 written in C++ (because of using bool, true, false and some other C++ only features). So, IMHO you should use "c++" (One more point: when you using "c++" or "g++" to compile C++ code it link it against libstdc++ (Standard C++ Library, new and delete operators is there) with gcc you should do this manually (-lstdc++)). If I wrong at some point, please correct me. Thanks and sorry my poor english. And why not to rename Linux port to Unix port? Happy coding =)

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Maybe just to make this a bit easier to understand

(note for the nitpickers, I''m using linked below even tho on some systems it''s not a link, but a actually copy of the executable. It doesn''t matter in this case tho)

Ok, on a linux/unix box, cc is linked to gcc or the system wide c compiler, c++ is linked to g++ or the system wide c++ compiler. Now, g++ is actually gcc with a flag that tells it to compile in c++ mode only, no matter the extention. By default gcc checks the extention and decides how to compile the file based on that.

Here''s the revelant quotes from the gcc manual:
"C++ source files conventionally use one of the suffixes .C, .cc, .cpp, .c++, .cp, or .cxx; preprocessed C++ files use the suffix .ii. GCC recognizes files with these names and compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc).

However, C++ programs often require class libraries as well as a compiler that understands the C++ language---and under some circumstances, you might want to compile programs from standard input, or otherwise without a suffix that flags them as C++ programs. g++ is a program that calls GCC with the default language set to C++, and automatically specifies linking against the C++ library. On many systems, g++ is also installed with the name c++."

So in short, you can set the make file to use cc, gcc, c++, or g++ and it will all use the same compiler.

Now, the portable way to do this is to use cc or c++, because if the admin of the computer sets up say intel''s c compiler as the default, it will use that. Now, because cc might be linked to intel''s c compiler, or let''s say joebob''s c compiler, it might not support c++, and thus if your writing c++, you should use c++ to be the compiler incase of odd setups like this.

Does anyone have any questions?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!