Search Results

Search found 1 results on 1 pages for 'mbyd'.

Page 1/1 | 1 

  • Is it better to use preprocessor directive or if(constant) statement?

    - by MByD
    Let's say we have a codebase that is used for many different costumer, and we have some code in it that relevant only for costumers of type X. Is it better to use preprocessor directives to include this code only in costumer of type X, or to use if statement, to be more clear: // some code #if TYPE_X_COSTUMER = 1 // do some things #endif // rest of the code or if(TYPE_X_COSTUMER) { // do some things } The arguments I can think about are: Preprocessor directive results in smaller code footprint and less branches (on non-optimizing compilers) If statements results with code that always compiles, e.g. if someone will make a mistake that will harm the irrelevant code for the project he works on, the error will still appear, and he will not corrupt the code base. Otherwise he will not be aware of the corruption. I was always been told to prefer the usage of the processor over the usage of the preprocessor (If this is an argument at all...) What is preferable - when talking about a code base for many different costumers?

    Read the article

1