3 ms·
That style of #ifdef use, while common in the past, tends to be somewhat fragile and also gets more and more tangled as more conditions are added. A better way
by cesarb 3y ago
That style of #ifdef use, while common in the past, tends to be somewhat fragile and also gets more and more tangled as more conditions are added.
A better way is to have an always existing inline running_on_valgrind() function, and use the #ifdef only for that function definition, either within it or around it (having it around the function also allows it to be inline only for the trivial not-defined case). Examples of this "inline function" style are found all over the Linux kernel (which has lots of conditionally-compiled code).