Conditional compilation


Conditional compilation is a compilation technique used in many programming languages. It depends on the compilation of the code fragments of the program from meeting the specified conditions.

This technique is used to create different versions of programs based on the same source code, for example for differentiation for test and final program.

The programming language for conditional compilation must have a conditional compilation directive and compile directives allowing defining conditions. The conditional compilation directive is in most cases modeled on a conditional statement.

An example of a language that supports conditional compilation is C, where it is supported on the preprocessor level. Example in C / C ++

Sample contents of test.c: #ifdef TEST double test = M_PI; #else float test = M_E; #endif

When compiling this computer program with a defined TEST macro (eg using gcc - gcc test.c - D TEST or by using the preprocessor directive #define TEST), this will be equivalent to double test = M_PI; In the program, the test variable will be double and will be given a value of π. By compiling the code without a defined TEST macro, we get M_E. Comments

wiki

Comments

Popular posts from this blog

Pupo Román

Myrmex Indikos

Names of streets and squares