On Wed, Jun 24, 2009 at 5:46 PM, Sanjeev
Gopinath<[email protected]> wrote:
>
>
> Hello all,
> I've some series of questions...!
> * Is there any difference when a C program runs in a C++ compiler?
> (I mean the approaches taken internally by the C++ compiler)
> * Will the C++ compiler understand it as a C program? If so, how does it
> differentiate?
> * Will there be any storage difference between a C and C++ compiler?
>
> Thanks in advance,
> Regards,
> Sanjeev Gopinath V
> sanjeevgopinath.blogspot.com
>
> [Non-text portions of this message have been removed]
>
>
This is about the first question i.e,
* Is there any difference when a C program runs in a C++ compiler?
I was surprised to know there is no difference between handling of .c
file and .cc file by a C++ compiler. To test this, i wrote just three
lines in a program:
void main()
{
}
i compiled this program using Dev C++ environment first as a .cc
program and then as a .c program.
while compileing it as .cc, i got error message that main() can return
only an int.
while compiling it as .c, i got only a warning.
on further investigation, i found that while Dev C++ uses g++ to
compile .cc file, it uses gcc to compile .c file. so what is the
difference between gcc and g++. as per my understanding, g++ is just a
script that invokes gcc only, though i am not very sure.
--Sanjeev Gupta