mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
implement G_STMT_START and G_STMT_END with do{}while(0), which is believed
2008-05-22 10:49:37 Tim Janik <timj@imendio.com> * glib/gmacros.h: implement G_STMT_START and G_STMT_END with do{}while(0), which is believed to be widely portable, fixes: Bug 519026 - G_STMT_START/G_STMT_END test a non-existent preprocessor symbol svn path=/trunk/; revision=6922
This commit is contained in:
parent
64e1b6d84f
commit
0782d697e5
@ -1,3 +1,9 @@
|
||||
2008-05-22 10:49:37 Tim Janik <timj@imendio.com>
|
||||
|
||||
* glib/gmacros.h: implement G_STMT_START and G_STMT_END with
|
||||
do{}while(0), which is believed to be widely portable, fixes:
|
||||
Bug 519026 - G_STMT_START/G_STMT_END test a non-existent preprocessor symbol
|
||||
|
||||
2008-05-20 Behdad Esfahbod <behdad@gnome.org>
|
||||
|
||||
Bug 501651 – Update glib/libcharset
|
||||
|
@ -216,31 +216,16 @@
|
||||
#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
|
||||
(*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
|
||||
|
||||
/* Provide simple macro statement wrappers (adapted from Perl):
|
||||
/* Provide simple macro statement wrappers:
|
||||
* G_STMT_START { statements; } G_STMT_END;
|
||||
* can be used as a single statement, as in
|
||||
* This can be used as a single statement, like:
|
||||
* if (x) G_STMT_START { ... } G_STMT_END; else ...
|
||||
*
|
||||
* When GCC is compiling C code in non-ANSI mode, it will use the
|
||||
* compiler __extension__ to wrap the statements wihin `({' and '})' braces.
|
||||
* When compiling on platforms where configure has defined
|
||||
* HAVE_DOWHILE_MACROS, statements will be wrapped with `do' and `while (0)'.
|
||||
* For any other platforms (SunOS4 is known to have this issue), wrap the
|
||||
* statements with `if (1)' and `else (void) 0'.
|
||||
* This intentionally does not use compiler extensions like GCC's '({...})' to
|
||||
* avoid portability issue or side effects when compiled with different compilers.
|
||||
*/
|
||||
#if !(defined (G_STMT_START) && defined (G_STMT_END))
|
||||
# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
|
||||
# define G_STMT_START (void) __extension__ (
|
||||
# define G_STMT_END )
|
||||
# else /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
|
||||
# if defined (HAVE_DOWHILE_MACROS)
|
||||
# define G_STMT_START do
|
||||
# define G_STMT_END while (0)
|
||||
# else /* !HAVE_DOWHILE_MACROS */
|
||||
# define G_STMT_START if (1)
|
||||
# define G_STMT_END else (void) 0
|
||||
# endif /* !HAVE_DOWHILE_MACROS */
|
||||
# endif /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
|
||||
#endif
|
||||
|
||||
/* Allow the app programmer to select whether or not return values
|
||||
|
Loading…
Reference in New Issue
Block a user