Thread: devc++ vs msvc++ - size

  1. #1
    Unregistered
    Guest

    devc++ vs msvc++ - size

    ok i know this has been covered before but i can't find it anywhere. when i enter this code:
    Code:
    #include <windows.h>
    
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow)
    {
    	MessageBox(0, "World", "Hello",0);
    
    	return 0;
    }
    into DevC++ the exe is 4kb but when i enter the same code into MSVC++ the exe is 24kb. why does msvc++ change the size so much? thanks.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    There's probably some compiler option to make the exe smaller, althoguh I can't think where that would be right now...

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Few reasons...

    Is MSVC set to release instead of debug?

    Has either compiler been set to optimise for size?

    Also the implementation of the libraries will be different between compilers...

    And I wouldnt trust such a small program as an indication of which compiler creates the smallest.

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Size matters not. Judge me by my size, do you? </yodavoice>
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Originally posted by Ken Fitlike
    UK has recently recognised Jedi Knight as a religion
    Not true, they have just added the religion "Jedi" to the census computers so it is recognised and does not produce a question. because of the amount of time they have to waste with all the false Jedi entries. It is still not an official religion.

  6. #6
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212

    Re: devc++ vs msvc++ - size

    Originally posted by Unregistered

    into DevC++ the exe is 4kb but when i enter the same code into MSVC++ the exe is 24kb. why does msvc++ change the size so much? thanks.
    Well, this code in MASM32

    Code:
    ; ######################################
    
        .486
        .model flat, stdcall
        option casemap :none   ; case sensitive
    
    ; ######################################
    
        include \masm32\include\windows.inc
        include \masm32\include\user32.inc
        include \masm32\include\kernel32.inc
        include \masm32\include\gdi32.inc
    
        includelib \masm32\lib\user32.lib
        includelib \masm32\lib\kernel32.lib
        includelib \masm32\lib\gdi32.lib
    
        main PROTO
    
        ; ---------------------
        ; literal string MACRO
        ; ---------------------
          literal MACRO quoted_text:VARARG
            LOCAL local_text
            .data
              local_text db quoted_text,0
            .code
            EXITM <local_text>
          ENDM
        ; --------------------------------
        ; string address in INVOKE format
        ; --------------------------------
          SADD MACRO quoted_text:VARARG
            EXITM <ADDR literal(quoted_text)>
          ENDM
    
    ; ##########################
    
        .code
    
    start:
    
        call main
    
        invoke ExitProcess,0
    
    ; #############################
    
    main proc
    
        invoke MessageBox,0,SADD("World"),SADD("Hello"),MB_OK
    
        ret
    
    main endp
    
    ; ###############################
    
    end start
    Makes an exe only 2.50KB. Yeah ASM wins! woo.

  7. #7
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Originally posted by Ken Fitlike


    None of them are.

    No, others are official religions. If you put Jedi on your job application you would probably be told to **** off.

  8. #8
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    there's been a 512 byte windows demo using opengl :P
    anybody seen stoerfaller ost?

    small code rocks
    .sect signature

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I'm a Jedi too -> click here

    On the note on executable size......so what!!
    ASM produces an executable thats 500 bytes smaller than a fully optimised executable.........big deal........The application, reusability and structure of a programming language is far more important than such a size difference.....

  10. #10
    Registered User
    Join Date
    Dec 2001
    Posts
    108
    Size matters not.
    I beg to disagree...

    When building an exe, you should always strive for balance between size and speed. The smaller the exe file is without loss of executable speed, the better. There should be no question to this logic whatsoever.

  11. #11
    Registered User
    Join Date
    Dec 2001
    Posts
    108
    On the note on executable size......so what!!
    ASM produces an executable thats 500 bytes smaller than a fully optimised executable.........big deal........The application, reusability and structure of a programming language is far more important than such a size difference.....

    Where are you coming from...

    I've seen some really stupid and bulky software written in HLL. Take for example the shareware "One Step Shutdown". This software is supposed to give the user the ability to quickly shut down their computer. This software is 2.9 Mb in size. I know of an ASM program only 1 Kb in size that does exactly the same thing, faster and safer. And it's FREE !

  12. #12
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >I beg to disagree...

    Well if you've only got an sizeof(operating system) + 2.50 Kb hard drive then I agree. But as hard drive space is cheap, developers don't have to spend time doing unnecessary optimisations (such as the c to asm conversion in this thread). Which means software is available earlier, and at cheaper cost.

    The only reason to be obsessive about size is when performance is critical (in which case only the parts of your program that need to run fast will benefit from being small), or if your programming in an environment that requires it.

  13. #13
    Registered User
    Join Date
    Dec 2001
    Posts
    108
    The only reason to be obsessive about size is when performance is critical

    Writing computer programs with the smallest and fastest possible code, should be the absolute goal of every good programmer, no matter what language he or she may use.

  14. #14
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by DarkStar
    Where are you coming from...

    I've seen some really stupid and bulky software written in HLL. Take for example the shareware "One Step Shutdown". This software is supposed to give the user the ability to quickly shut down their computer. This software is 2.9 Mb in size. I know of an ASM program only 1 Kb in size that does exactly the same thing, faster and safer. And it's FREE !
    As far as I can see the example you provided shows little or no comparison to the case in point....

    Agreed.....some freeware piece of junk that takes 3MB to shutdown a system is excessive and rather wastefull, but a size loss of 500 bytes to build the executable listed at the head of this thread in C/C++ is probably worth it when you compare it to the extra work gone into the ASM example that Brian has also provided earlier....
    Last edited by Fordy; 03-01-2002 at 06:02 PM.

  15. #15
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >Writing computer programs with the smallest and fastest possible code, should be the absolute goal of every good programmer, no matter what language he or she may use.

    Why? I'm not saying that it's not better to produce smaller code if there are no other major costs/effort involved. But if you're paying more for your software as a result there's little sense in going to extremes (unless you're living in a world where programmers get as much time as they require and all software is free).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heapsort
    By xENGINEERx in forum C Programming
    Replies: 2
    Last Post: 03-30-2008, 07:17 PM
  2. Pointer Size Relative To Integers?
    By SMurf in forum C Programming
    Replies: 1
    Last Post: 04-18-2006, 06:58 AM
  3. Invalid conversion from 'void*' to 'BYTE' help
    By bikr692002 in forum C++ Programming
    Replies: 9
    Last Post: 02-22-2006, 11:27 AM
  4. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM