[lkml]   [1996]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Problem: __inline__ functions in the kernel & cli()/sti() latency measurement
:    Also, you can't return a value from a macro like that.  You can
: from an inline function.
: Untrue:
: #define val_plus_two(val) do { ((val) + 2); } while(0)
: It still does not annul the multi-evaluation reasoning for using
: inline functions instead of macros though ;-)

No, your assertion is untrue :-)

a = val_plus_two( val )

would expand to

a = do { ((val) + 2); } while (0 );

which is illegal in C. gcc doesn't even have this extension and gives
a parse error at the "do" (at least for 2.6.3 and 2.7.2).

What your construct does do is make it safe to be used in an
"statement" context, but not an expression context.

While you can do very very very simple things that return a value, you
can't have a macro that walks a list and returns something out of the
middle of the list (unless you cunningly cached a pointer to it

This, imho, is one of the flaws in the C language where it doesn't
quite hang right together.


 \ /
  Last update: 2005-03-22 13:37    [W:0.031 / U:3.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site