Is there a way to set the value of #define on runtime?

c#, c-preprocessor

Solution

Absolutely not, #defines are compiled out by the preprocessor before the compiler even sees it - so the token 'oracle' isn't even in your code, just '1' or '0'. Change the #define to a global variable or (better) a function that returns the correct value.

Problem

I wonder if there is a way to set the value of #define in run time. I assume that there is a query for Oracle specific and Sql Server specific at the code below. ``` #define oracle // ... #if oracle // some code #else // some different code. #endif ```

Original source

Related problems