|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
ASM vs C filesize
Ok, I am learning C at the moment, I came from a win32asm background. I want to know why C executables are so big. If I just make a window in masm for example, It's about 3K, and in C it's around 21K, why is it that big, I am using API in both, and the C code is turned into machine code (asm too), so what's the diff? If I don't use a function in windows.h, It doesn't get included right? I heard something about WIN32_LEAN_AND_MEAN.
|
|
#2
|
||||
|
||||
|
Here is an excerpt from the MSDN Lib:
"To improve build times and reduce the size of your application's precompiled header, MFC defines the symbol WIN32_LEAN_AND_MEAN. This definition lists a group of less commonly used header files that MFC does not automatically include through including AFXWIN.H. To see the list of header files specifically excluded from MFC builds, look at the definition of WIN32_LEAN_AND_MEAN in WINDOWS.H. If you need the definitions provided by any of those files, you must explicitly include the appropriate file yourself. WIN32_LEAN_AND_MEAN was not defined in MFC version 2.1, and all of the extra headers were included." So there you have it, to use the code just put: Code:
#define WIN32_LEAN_AND_MEAN At the top. HTH
__________________
--------------------- -- SilkySmooth -- --------------------- Proxy | Little Directory |
|
#3
|
||||
|
||||
|
That's because C executables have extra startup code that is added on to every executable. In Turbo C, this code was in a file called C0x.asm, where x could be t, s, m etc. depending on your memory model used (t = tiny, s = small, h = huge etc.). Most of the startup code would set up the stack, check version numbers, set up some compiler specific pre-defined vars etc. You could fiddle with it and set up your own startup executables.
Also, depending on your compiler settings, you could also be including debug information in your executable. Another thing to remember is that, functions such as printf() don't just translate to a quick INT21 call. This is because printf() is build to handle a variety of formats such as strings, numbers, floats etc. and therefore adding a printf() to your code increases the executable size significantly. For an interesting discussion on how to make really small executables, see this link: http://www.muppetlabs.com/~breadbox...iny/teensy.html |
![]() |
| Viewing: Dev Shed Forums > Other > Dev Shed Lounge > ASM vs C filesize |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|