On 4/19/14, 1:09 PM, Filip Pizlo wrote: > When guarding code with macros that are always defined, such as > ASSERT_DISABLED (it's always either 0 or 1), we have a choice between: > > if (!ASSERT_DISABLED) { > // do things > } > > and: > > #if !ASSERT_DISABLED > // do things > #endif > > I'd like to propose that /anytime the normal if would be semantically > equivalent to the preprocessor #if, the normal if should be used/. > > We don't lose any compiler optimization, since even at -O0, the compiler > will constant fold the normal if. We do gain a lot of clarity, since > the control flow of normal if statements is subject to proper indentation. > > The "semantically equivalent" requirement still allows for #if to be > used for thinngs like: > > - Guarding the placement of fields in a class. > - Guarding the definitions of other macros (in the case of > ASSERT_DISABLED, we define ASSERT in different ways guarded by #if's) > - Guarding the definition/declaration/inclusion of entire functions, > classes, and other top-level constructs.
This is adding complexity for little gain. I would not mind replacing all the macros by real if() branches, but that is not possible in plenty of cases. Using both the branches and the macro seems like a bad idea. Benjamin _______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev