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.
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.
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.
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:
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.
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.
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 :)
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.
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 ;)
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.
Jibz' our hero :)