How to use enum values to direct compilation with preprocessor directives
<p>I want to select a portion of my code for compilation based on an enum value. So, how can I combine the use of enum with preprocessor directives to achieve this goal?
An example is like the following:</p>

<pre><code>#include &lt;iostream&gt;

enum CODE {BINARY, PERMUTATION, BYVALUE};

#define ENCODING(x) (x)

using namespace std;

int main()
{
    CODE code = PERMUTATION;
#if ENCODING(code) == BINARY
    cout &lt;&lt; "code: BINARY" &lt;&lt; endl;
#elif ENCODING(code) == PERMUTATION
    cout &lt;&lt; "code: PERMUTATION" &lt;&lt; endl;
#elif ENCODING(code) == BYVALUE
    cout &lt;&lt; "code: BYVALUE" &lt;&lt; endl;
#endif
    return 0;
}
</code></pre>

<p>Obviously, this is not correct to get my aim as it always takes the first #if statement and displays "code: BINARY".
Is there any way to use the enum to control the compiled segments?
Thank you.</p>
