Re: [PATCH] Dynamic tick for x86 version 050602-2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jun 10, 2005, at 05:15:15, Pavel Machek wrote:
Hi!
do {} while (0)

, else you are preparing trap for someone.


Can you please explain what the difference between these two are?
Some compiler version specific thing?


It took me quite some remembering. Problem is that with your macros,
someone can write

    dyn_tick_reprogram_timer()
    printk();

[notice missing ; at first line], and still get it compile. If you
replace {} with do {} while (0), he'll get compile error as he should.

Actually, the real reason is for something like this:

#define myfunc1() {}
#define myfunc2() {}

if (a && b) myfunc1();
else        myfunc2();

This would be translated as:

if (a && b) {};
else        {};

Which would generate a syntax error:
zeus:~ kyle$ gcc -c `y -e .c` -o tmp.o <<'EOF'
> #define myfunc1() {}
> #define myfunc2() {}
> void x() {
>     int a = 0, b = 1;
>     if (a && b) myfunc1();
>     else        myfunc2();
> }
> EOF
/tmp/y.c8F08d.c: In function ‘x’:
/tmp/y.c8F08d.c:4: error: parse error before "else"

Cheers,
Kyle Moffett



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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux