Tiny C startup module to build smaller C executables

Started by Vortex, December 25, 2004, 02:36:17 PM

Previous topic - Next topic

Vortex

Hi friends,

Here are two versions of my tiny C startup modules, one for console applications, the other one for GUI apps.
Both op the modules has the capacity of handling command line parameters.

Reducing the size of C executables, these modules are designed to use with Visual C and Pelle's C compilers.

Builded with these tiny modules, a simple application displaying a blank window is only 2 / 2.5 Kb


[attachment deleted by admin]

Vortex

Here is another version of the example compiled with Visual C, this one linked with Polink : final size = 1.5 Kb

[attachment deleted by admin]

Opcode

Hi Vortex!

Very interesting work  :U

Can you explain me better the cl.exe option /Ogtyb2
I have readed the http://msdn.microsoft.com/library/en-us/vccore/html/_core_.2f.Og.asp, but
I don't have understood it very well...

Regards,
Opcode

Vortex

Hi Opcode,

The switch /Ogtyb2 is a subset of /Ogityb2 maximizing optimizations. Type cl /? to see all the switches of the compiler coming with the free toolkit 2003 package:
Quote/O1 minimize space                       /Op[-] improve floating-pt consistency
/O2 maximize speed                       /Os favor code space
/Oa assume no aliasing                   /Ot favor code speed
/Ob<n> inline expansion (default n=0)    /Ow assume cross-function aliasing
/Od disable optimizations (default)      /Ox maximum opts. (/Ogityb2 /Gs)
/Og enable global optimization           /Oy[-] enable frame pointer omission
/Oi enable intrinsic functions

Jibz

[plug]

In case anybody needs something similar, but is willing to sacrifice slightly more space to get support for more of the standard C runtime library, you might also want to check out LIBCTINY by Matt Pietrek or WCRT by me :U.

But Vortex' library gives the smallest executables (except for skipping startup code alltogether of course).

[/plug]

Vortex

Here are three new examples for PellesC, one for console applications, the other one for GUI apps and the last one for DLLs

[attachment deleted by admin]

Xor Stance

#6
Hi Jibz and Pelles C/C++ and Visual Studio :green, will their be an implement for C++ library?


mariø

thanks a lot Vortex :clap:
now i understand better what C must do at startup.

Xor Stance

 :U I forgot to mention Vortex, they're expertise in C/C++ and Visual Studio(maybe). :green

Vortex

Here is an example for the Digital Mars compiler.

[attachment deleted by admin]

Vortex

Is there anyone using Borland C++ 5.5? Maybe, I can try creating a startup module for this compiler.

pbrennick

Vortex,
Thank you the the Digital Mars example.

Paul

Vortex

Here is the same example compiled with GCC V3.2.3 from the MinGW package V3.1.0.1

[attachment deleted by admin]

Phil

Thank you for sharing your code, Vortex. I have encapsulated it in the Fibonacci program I am working on. I still haven't quite figured out how you handle the quoted arguments so gracefully but I think your code is awesome! I'll credit you in my comments if its okay for me too keep your code there. (BTW, I'll eventually figure out how your xor is doing its magic but I just thought I'd let you know it wasn't obvious to me during the 2nd and 3rd reads! ;)