RE: do { } while (0) question



#if KILLER == 1
#define MACRO
#else
#define MACRO do { } while (0)
#endif

{
if (some_condition)
MACRO

if_this_is_not_called_you_loose_your_data();
}

How do you want to define KILLER, 0 or 1? I personally choose 0.

Really? Does it compile?

Hua

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Compile time string literal substitution to external data file
    ... and these string literals may expose sensitive information ... > I want to use the compile time macros for file name, line number, and ... I'd put a macro and a function like: ...
    (microsoft.public.vc.language)
  • Re: do { } while (0) question
    ... How do you want to define KILLER, ... Does it compile? ... The empty 'do while ' makes the missing semicolon a syntax error. ...
    (Linux-Kernel)
  • Re: do { } while (0) question
    ... #define MACRO ... How do you want to define KILLER, ... I can't emit an error with the thing like that, only a warning, but we are not using -Werror to get err from a warn. ...
    (Linux-Kernel)
  • Re: do { } while (0) question
    ... #define MACRO ... How do you want to define KILLER, ... Does it compile? ... The empty 'do while ' makes the missing semicolon a syntax error. ...
    (Linux-Kernel)
  • Re: Macro to cause build failure if parameter not defined?
    ... this in a macro: ... What I want is a way to test if a feature flag is defined to 1 such ... compile flags, or they just typed it wrong. ...
    (comp.lang.c)