which compiler to use? GCC or G++

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

which compiler to use? GCC or G++

Post 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
Legend
Member
Member
Posts: 195
Joined: Tue Nov 02, 2004 12:00 am
Contact:

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

Post 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!
*post*
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

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

Post 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 .
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
bregma
Member
Member
Posts: 25
Joined: Tue Oct 26, 2004 11:00 pm
Location: the back woods
Contact:

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

Post 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.
Post Reply