Hi friends,

Here are two versions of my tiny C startup modules, one for console applications, the other one for GUI apps.
Both of 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

Click here to download the example project.
Posted on 2005-01-09 04:45:14 by Vortex
http://www.ibsensoftware.com/files/WCRT-1.12.zip :) - tiny, but still offers a lot of libc features, including initialization of global objects and such.
Posted on 2005-01-09 05:42:26 by f0dder
its annoying to have to link something else to a quick console project, usually, i just stick this tiny wrapper in front of my vc++ exes, which does pretty much the same as the startup routines:

void entry()

{
typedef int (__cdecl *GETMAINARGS)(int*, char***, char***, int, int*);

int argc;
char** argv;
char** env;
int new_mode = 0;
GETMAINARGS getmainargs;

getmainargs = (GETMAINARGS) GetProcAddress(LoadLibrary("msvcrt"),"__getmainargs");
getmainargs(&argc,&argv,&env,0,&new_mode);
main(argc,argv,env);
exit(0);
}


msvc doesnt recognize __getmainargs, and i didn't bother to look up how to import static functions, so... it's a fast fix. all i do is add "msvcrt.lib" into the list of linked libs, change entrypoint to entry(), some other stuff like disabling exception handling, etc. and then merging/realigning the sections. seems like the best way to make tiny exes and still use all the argument stuff.
Posted on 2005-01-12 17:13:01 by Drocon
Drocon, that introduced a dependency on msvcrt though - the code in that dll is sorta slow, and it has some bugs. It's not that much of a deal to add Jibz' wcrt, and it's very nice. He's working on floating point support for printf right now, it's becoming a very decent libc replacement :)
Posted on 2005-01-12 17:20:08 by f0dder
http://www.ibsensoftware.com/files/WCRT-1.12.zip :) - tiny, but still offers a lot of libc features, including initialization of global objects and such.


Yes, that library is a nice project. My intention to code my own modules is to create small executables with a minimal overhead.
Posted on 2005-01-13 04:51:44 by Vortex

create small executables with a minimal overhead.

...and that's what WCRT is, while still giving you access to libc.
Ok ok, I'll get off your back now ;)
Posted on 2005-01-13 05:12:29 by f0dder
the only reason i keep msvcrt is so that a lot of stuff can be statically linked, but yes, WCRT is very nice, there's absolutely no doubt A LOT of painstaking effort was put into making it small and optimized.
Posted on 2005-01-13 20:52:50 by Drocon
Jibz' our hero :)
Posted on 2005-01-13 21:52:37 by f0dder