Conditional Compilation

The preprocessor also facilitates conditional compilation. See below to find out how.

We'll cover the following

Conditional Compilation

One can use #ifdef, #endif, #else and #ifndef statements to achieve conditional compilation, for example to create one program that can be compiled and 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 that, we’re done with the preprocessor. As always, there are some helpful links in the next lesson.

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