On Apr 20, 2014, at 1:19 PM, Mark Rowe <[email protected]> wrote:

> 
> 
> Won’t compile:
> 
> if (!MAYBE_DEFINED) {
>     …
> }
> 
> if (SOMETHING) {
>     void doSomething() { }
> }
> 
> if (SOMETHING) {
>     #include “Something.h"
> }
> 
> 
> Will result in unintended behavior:
> 
> if (!FOO) {
>     …
> #define BAR
>     …
> }

We clearly can’t use if() to replace #if in general. Let’s assume that we 
reject a universal proposal of that sort.

However, it seems like the above examples will generally not apply in the case 
of the switch for assertions being enabled or disabled. Or at least I would not 
expect it - do you know of such cases in the code?

One worry about Phil’s proposal is that we’d be making asserts enabled/disabled 
different from handling of other conditional preprocessor macros. One possible 
way to avoid this is to make asserts enabled/disabled a compile-time constant 
held in a const global variable instead. That would enforce this style and make 
it natural.

I am not sure offhand if this is actually viable, but I see no deep reason that 
assertion control has to be just like the conditional macros we use to avoid 
submitting code to the compiler that won’t actually compile.

Regards,
Maciej



_______________________________________________
webkit-dev mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to