This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Why this difference ?
- From: Dileep Krishnan <dileepkrishnan at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 25 Aug 2005 10:08:33 +0530
- Subject: Why this difference ?
- References: <c8508e9e05082421347d37f76f@mail.gmail.com>
Sir,
>From the FAQ section of your home page I came to
know that there is little difference between executables
generated by C and C++ compilers for a 'Hello World'
program.
I found that this is exactly the case of gcc-3.4 in my
Debian Linux. The size of the C-executable is 11521
bytes and C++ executable is 13568 bytes.
But the behaviour is quite different in Windows XP.
I have installed gcc-mingw(gcc version 3.4, mingw
version 4.1.1) on my WinXP. I tried the same
'Hello World' programs. I had used 'gcc -o2' &
'g++ -o2' for compiling, just as you had mentioned
in the FAQ. This time the size of the exe's are drastically
different. The C-exe is 15,661 bytes & the C++ exe is
474,849 bytes.
The C++ exe is 30 times the size of the C exe.
Could you please tell me why this happens and what I
should do about it? Is there anything I have missed
to do?
The C source code is as follows:
**********************************
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hai!!!\n");
return 0;
}
**********************************
The C++ source code is as follows:
*************************************
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hai!!!!" << endl;
return 0;
}
*************************************
Thanking You,
Regards,
Dileep
--