www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1998/05/20/15:09:16

X-pop3-spooler: POP3MAIL 2.1.0 b 4 980420 -bs-
Delivered-To: pcg AT goof DOT com
Message-Id: <m0ycANJ-0001YMC@Dirac.Chemie.FU-Berlin.DE>
From: melchers AT chemie DOT fu-berlin DOT de (Bernd Melchers)
Subject: Re: size differences g++ en gcc
To: Remco DOT vdBerg AT ehv DOT sc DOT philips DOT com (Remco van den Berg)
Date: Wed, 20 May 1998 17:01:49 +0200 (MEST)
Cc: beastium-list AT Desk DOT nl
In-Reply-To: <3562EC4C.41F93E45@ehv.sc.philips.com> from "Remco van den Berg" at May 20, 98 04:44:28 pm
X-Mailer: ELM [version 2.4 PL24 ME8d]
MIME-Version: 1.0
Sender: Marc Lehmann <pcg AT goof DOT com>
Status: RO
Lines: 58

'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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019