How to get a boolean indicating if a macro is defined or not?
<p>My code is configurable with define macros. To get the value in the code, I'm doing this: </p>

<pre><code>#ifdef CONFIG_X
static constexpr bool x = true;
#else
static constexpr bool x = false;
#endif
</code></pre>

<p>But this is quickly becoming very ugly in the code with several configuration variables...</p>

<p>Another solution I found is simply to cut the code in two: </p>

<pre><code>#ifdef CONFIG_X
#define CONFIG_X_BOOL true
#else
#define CONFIG_X_BOOL false
#endif

static constexpr bool x = CONFIG_X_BOOL;
</code></pre>

<p>This is a bit better, but not really nice either.</p>

<p>Is there a nice way to have a boolean or a 1 or 0 if a macro is defined ?</p>