Conditional Compilation

Learn how the preprocessor also facilitates conditional compilation.

We'll cover the following

A note on conditional compilation

One can use #ifdef, #endif, #else and #ifndef statements to achieve conditional compilation. For example, to create a program that can be compiled conditionally to run on different computer systems.

Similarly, one can use #if, #elif preprocessor statements to define macros differently depending on the value of other #define values. We won’t get into that stuff here, but if you’re interested in this you can look at some examples here.

With this brief note, we’re done with the preprocessor.

In the section that follows, we’ll learn different conventions related to how code should be structured and stored. See you there!

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy