3 ms·
It's quite common in large C programs to have setups where some code might be under an if() statement and the if() condition is something that is compile-time 0
by pm215 2y ago
It's quite common in large C programs to have setups where some code might be under an if() statement and the if() condition is something that is compile-time 0 if support for a feature wasn't compiled in. (The idea is that you get syntax checking in a way that you don't for just ifdeffing-out the code, and you don't get weird nesting of preprocessor ifdefs with C ifs.) If you warn about the elimination of code like that, it makes that technique rather awkward.
(For instance, in QEMU we have code like: "if (kvm_enabled()) { do_something_kvm_specific(); }". In a no-KVM build, kvm_enabled() evaluates to compile-time false, and in a KVM build it does a runtime check of whether the user turned on KVM for this run.)