Mini CRT

Introduction
The stock C Run-Time library that comes with most compilers is very cluttered object. Most of the stuff in there you will never use, and the rest is set up so that it has a lot of flexibility - for example, you can use fprintf to go to a file, a printer, or the screen. This is all well and fine when you're writing a medium-to-large app, but what about when you don't care about all these goodies?

While I was writing RRloginV3, I was annoyed with the fact that I could not get my program down in size, even though the resulting .OBJ files were smallish. Even with Aggressive Optimization put in, I was still getting bloatware. The Visual C++ runtime libs were pulling in lots of stuff I didn't need, mostly dealing with C++ constructors, exception handlers, etc. If you are writing a small device driver or a control panel applet (or service!), you probably don't need these fancy things and can design around the rest.

In order to keep things from getting screwy, and to prevent myself from accidentally using the CRT functions, I use different naming, with correct upper/lower case mix. For example, memcpy becomes CopyMem. time is called GetCurrentSeconds. As so on.

There is one caveat with using this: you can no longer have class objects created and destroyed for you. In other words, let's say you have:

    Fred    g_theFred;

With the standard CRT, g_theFred will be created and destroyed for you. With MiniCRT, it won't. In order to roll-you-own, you would declare g_theFred as a pointer, and use new in your Main function to create it. Then use delete when you exit to get rid of it. For a fully working example of this, see RRLoginV3's source code.

You will probably find that you will need to modify MiniCRT for your own needs. That's cool - it's a freebe.

Downloads:

MiniCRT cpp and header file, zipped: MiniCRT.zip


Updated: Thursday, Sep 18, 2008
Contents copyright © 1999-2003 by NOPcode.com and its subsidiaries. Reproduction in part or in whole prohibited unless explicitly granted. All information and products, be it documentation, essays, source code, programs, or installs, are provided "as-is" and neither the author nor NOPcode.com will be held responsible for any resulting damages, either physical or mental. No warranty is expressed nor implied. All rights reserved. All trademarks used are property of their respected companies. For further information contact .