mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
Avoid warning when using G_STMT_END macro with MSVC
Workaround found on http://cnicholson.net/2009/03/stupid-c-tricks-dowhile0-and-c4127/ https://bugzilla.gnome.org/show_bug.cgi?id=742851
This commit is contained in:
parent
432476355b
commit
7a8ef00aae
@ -279,11 +279,21 @@
|
||||
* if (x) G_STMT_START { ... } G_STMT_END; else ...
|
||||
* This intentionally does not use compiler extensions like GCC's '({...})' to
|
||||
* avoid portability issue or side effects when compiled with different compilers.
|
||||
* MSVC complains about "while(0)": C4127: “Conditional expression is constant”,
|
||||
* so we use __pragma to avoid the warning since the use here is intentional.
|
||||
*/
|
||||
#if !(defined (G_STMT_START) && defined (G_STMT_END))
|
||||
#define G_STMT_START do
|
||||
#if defined (_MSC_VER) && (_MSC_VER >= 1500)
|
||||
#define G_STMT_END \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4127)) \
|
||||
while(0) \
|
||||
__pragma(warning(pop))
|
||||
#else
|
||||
#define G_STMT_END while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Deprecated -- do not use. */
|
||||
#ifndef G_DISABLE_DEPRECATED
|
||||
|
Loading…
Reference in New Issue
Block a user