I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the "math.h" header, need to be linked in manually when included. I have been linking in the libraries using various flags of the form
such as -lm for the above-mentioned math library.
However, after switching from the command line and/or Geany to Code::Blocks, I noticed that Code::Blocks uses g++ to compile the programs instead of the gcc that I am used to (even though the project is definitely specified as C). Also, Code::Blocks does not require the libraries to be manually linked in when compiling - libraries such as the math library just work
I have two questions:
Firstly, is it "bad" to compile C programs with the g++ compiler? So far it seems to work, but after all, C++ is not C and I am quite sure that the g++ compiler is meant for C++.
Secondly, is it the g++ compiler that is doing the automatic linking of the libraries in Code::Blocks?