Page 1 of 1

which compiler to use? GCC or G++

Posted: Tue Apr 05, 2005 11:00 pm
by prajwal
which compiler is better.... to compile a os written in 'C'

gcc by default uses C99 Std =>
no for(int i = 0.........),
if a parameter to a function is a enum then
gcc allows any int var to be passed as parameter but g++ does a
strong type checking

ex:- typedef enum { x, y } SAMPLE ; int fun(SAMPLE sam) { .. }

a call like fun(10) is allowed in gcc but not in g++....

Is there any advantages at code generation level by using g++ over gcc

finally which one to use g++/gcc to build ur OS written in 'C' on a Linux machine

Re: which compiler to use? GCC or G++

Posted: Tue Apr 05, 2005 11:00 pm
by Legend
For C normally gcc works a good bit better then g++, as g++ aims on C++! This is also one reason why g++ does stronger type checking then gcc!

Re: which compiler to use? GCC or G++

Posted: Wed Apr 06, 2005 11:00 pm
by [AlAdDiN]
it you want to write TRUE C OS you have to use gcc and ansi C syntax ...
g++ is a c++ compiler, but as you know, you can write non Oriented Object programs in C++ the work just fine, but it doesn't mean thet those are C programs : for example if you write for (int i = 0; ...), this will not compil on a "C" compiler, but in C++ compiler only .

Re: which compiler to use? GCC or G++

Posted: Wed Apr 06, 2005 11:00 pm
by bregma
srinivasa_prajwal wrote: which compiler is better.... to compile a os written in 'C'
Is there any advantages at code generation level by using g++ over gcc
Both the g++ and gcc front ends use the same middle and back ends, so unless you're using C++ constructs not found in C you will get no difference in the generated code.

The stronger compile-time enforcements of C++ provide you with an opportunity to practice better discipline in your development efforts, something that has been shown to reduce bugs and maintenance costs over the long run. You can achieve similar benefits using a C compiler and the rigourous application of external tools such as "lint". The choice is up to you, but I would suggest that the automation of repetitive and automatable tasks (such as running "lint" on every build or using a C++ compiler on C code) will only benefit you.