[Freeciv-Dev] (PR#15158) __extension__ keyword in gui-sdl
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15158 >
> [jdorje - Sa 14. Jan 2006, 19:15:10]:
>
>
> I can see no reason why it would be there. Was it always there? Is it
> there in 1.14?
>
> -jason
>
SVN history shows the following:
in r5500 (first version of the SDL client in Freeciv repository) it
looked like this
#define get_wstate(pWidget) \
( __extension__ \
(pWidget->state_types_flags & STATE_MASK) \
)
in r5831 the fc__extension macro was introduced and the macro above
changed to
#define get_wstate(pWidget) \
fc__extension(pWidget->state_types_flags & STATE_MASK)
the Log entry says "Correct __extension__ calls."
in r5968 the scrollbar_size macro was introduced
#define scrollbar_size(pScroll) \
fc__extension((float)((float)(pScroll->active) /
(float)pScroll->count) * \
(pScroll->max - pScroll->min))
in r6082 the "state flags" were changed to an enum type and we got
#define get_wstate(pWidget) \
fc__extension((enum WState)(pWidget->state_types_flags & STATE_MASK))
which is the current version.
So it now appears to me that the __extension__ keyword was necessary in
the first version because of the braces (when the macro was used inside
an expression)
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Statement-Exprs.html
That would mean the problem had already been solved by removing the
braces in r5831.
Ok, I think I understand now :-)
There is a problem with macros that have braces and "return a value".
Using "do{}while(0)" is not possible in this case, so you need to make
use of the GCC extension or write a function. Then Rafal created the
fc__extension macro to use with macros of this type and used it even if
there were no braces at all.
That would also make Raimar Falke's patch in PR#3608 a bit clearer to
me. So I think the fc__extension macro can be safely removed and it's
generally better to use functions instead for the kind of macros that
would have needed it. Agreed?
|
|