Wednesday, May 19, 2010

Conditional Compilation

Today in class, I learned what the true value of the "#" is used for. It is used before compilation begins. That means anything with the # sign will be done first before the "actual" program starts to compile and run. This helps a lot with the different compilation we need to do later.

For example:

#define DoIt

Int main() {
#ifdef DoIt
Double a = 1.12
Double b = 2.12
#endif


if #define DoIt doesn't exist then the Double a = 1.12 and Double b = 2.12 would not compile (it'll be skipped during compilation)

No comments:

Post a Comment