Mail Archives: pgcc/1998/05/20/15:09:16
'Remco van den Berg wrote:'
>
> Can somebody explain to me why normal C code compiled with G++ is
> smaller in size than when I compile it with GCC ?
you simply can disassemble the code or compile to assembler
code ( gcc -S ) and compare it:
% size gpptest gcctest
text data bss dec hex filename
1071 220 4 1295 50f gpptest
1016 196 4 1216 4c0 gcctest
gcc-2.7.2.1 produces:
....
addl $4,%esp
xorl %eax,%eax
jmp .L1
.align 16
..L1:
movl %ebp,%esp
....
and g++ produces
addl $4,%esp
xorl %eax,%eax
jmp .L1
.align 16
xorl %eax,%eax
jmp .L1
.align 16
..L1:
movl %ebp,%esp
dont know, maybe other default flags in the specs file?
>
> For example, this very original program:
>
> #include <stdio.h>
> int main(void)
> {
> printf( "Hello world!\n" );
> return 0;
> }
>
> compiles into a 6532 bytes 'big' executable using `gcc main.c`.
> (After stripping.)
> Using g++ it's only 3032 bytes of size.
>
--
Bernd Melchers | melchers AT FU-Berlin DOT DE
Freie Universitaet Berlin | "We don't write software, we compose it."
AG Macromelecular Modelling - Prof. Dr. E.W. Knapp
for more information see http://www.chemie.fu-berlin.de/~melchers/
- Raw text -