The Power of Conditional Compilation

© Guy Lecky-Thompson

Aug 18, 2006

In this modern world of multi-platform, cross-platform programming, it's sometimes useful to be able to select what we compile.


I used to detest creating multiple makefiles for all my programming projects. Sometimes I'd end up with one for Win16, one for Win32 and another for some esoteric Unix box. All command line programs, all supposedly written in ANSI C, but all using different compilers and language variants.

One solution is to use Conditional Compilation. This is slightly different from conditional execution - which amounts to an if statement - in that the decision process takes place during the evalution to the pre processor directives.

If this is Greek to you, then you definately need to read Conditional Compilation in C as it will help you to understand the concept, as well as it's application under the C language.

Many languages also share the concept, with varying degrees of efficacy and success. If you want to share your experiences and best practices, then drop me a line, and we'll start a discussion!


Post this Blog to facebook Add this Blog to del.icio.us! Digg this Blog furl this Blog Add this Blog to Reddit Add this Blog to Technorati Add this Blog to Newsvine Add this Blog to Windows Live Add this Blog to Yahoo Add this Blog to StumbleUpon Add this Blog to BlinkLists Add this Blog to Spurl Add this Blog to Google Add this Blog to Ask Add this Blog to Squidoo