3 ms·
The compiler constantly makes judgement calls on whether or not your code needs to run. For instance: if (something) do_something(); Elsewhere:
by JoshTriplett 12y ago
The compiler constantly makes judgement calls on whether or not your code needs to run.
For instance:
if (something)
do_something();
Elsewhere:
#ifdef CONFIG_RUNTIME_ENABLE_SOMETHING
bool something = false;
/* and some means of changing something at runtime */
#else
const bool something = false;
#endif
If you don't define CONFIG_RUNTIME_ENABLE_SOMETHING, and thus "something" cannot change at runtime, then the compiler should recognize the if as always false and throw away the call to do_something(). If that was the only call to do_something(), it should throw away the code of do_something().