Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 12th, 2003, 03:35 PM
movEAX_444's Avatar
movEAX_444 movEAX_444 is offline
Cast down
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Sweden
Posts: 321 movEAX_444 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 56 m 35 sec
Reputation Power: 6
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.

Reply With Quote
  #2  
Old July 12th, 2003, 03:58 PM
SilkySmooth's Avatar
SilkySmooth SilkySmooth is offline
Newbie :P
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2001
Location: In the PHP Engine :-)
Posts: 2,880 SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 32 m 23 sec
Reputation Power: 15
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

Reply With Quote
  #3  
Old July 12th, 2003, 04:03 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,589 Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 1 m 37 sec
Reputation Power: 1001
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDev Shed Lounge > ASM vs C filesize


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT