wxCALL_FOR_EACH compilation fix for VC++.
VC++ has a bug where __VA_ARGS__ is incorrectly expanded as a single token, contrary to C99. The solution is to pass the arguments to another macro as a single token inside parenthesis. See http://stackoverflow.com/questions/9183993/msvc-variadic-macro-expansion for the gory details. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72850 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -128,8 +128,8 @@
|
|||||||
(With thanks to https://groups.google.com/d/topic/comp.std.c/d-6Mj5Lko_s/discussion
|
(With thanks to https://groups.google.com/d/topic/comp.std.c/d-6Mj5Lko_s/discussion
|
||||||
and http://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros)
|
and http://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros)
|
||||||
*/
|
*/
|
||||||
#define wxCALL_FOR_EACH_NARG(...) wxCALL_FOR_EACH_NARG_(__VA_ARGS__, wxCALL_FOR_EACH_RSEQ_N())
|
#define wxCALL_FOR_EACH_NARG(...) wxCALL_FOR_EACH_NARG_((__VA_ARGS__, wxCALL_FOR_EACH_RSEQ_N()))
|
||||||
#define wxCALL_FOR_EACH_NARG_(...) wxCALL_FOR_EACH_ARG_N(__VA_ARGS__)
|
#define wxCALL_FOR_EACH_NARG_(args) wxCALL_FOR_EACH_ARG_N args
|
||||||
#define wxCALL_FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
|
#define wxCALL_FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
|
||||||
#define wxCALL_FOR_EACH_RSEQ_N() 8, 7, 6, 5, 4, 3, 2, 1, 0
|
#define wxCALL_FOR_EACH_RSEQ_N() 8, 7, 6, 5, 4, 3, 2, 1, 0
|
||||||
|
|
||||||
@@ -142,11 +142,11 @@
|
|||||||
#define wxCALL_FOR_EACH_7(what, x, ...) what(7, x) wxCALL_FOR_EACH_6(what, __VA_ARGS__)
|
#define wxCALL_FOR_EACH_7(what, x, ...) what(7, x) wxCALL_FOR_EACH_6(what, __VA_ARGS__)
|
||||||
#define wxCALL_FOR_EACH_8(what, x, ...) what(8, x) wxCALL_FOR_EACH_7(what, __VA_ARGS__)
|
#define wxCALL_FOR_EACH_8(what, x, ...) what(8, x) wxCALL_FOR_EACH_7(what, __VA_ARGS__)
|
||||||
|
|
||||||
#define wxCALL_FOR_EACH_(N, what, ...) \
|
#define wxCALL_FOR_EACH_(N, args) \
|
||||||
wxCONCAT(wxCALL_FOR_EACH_, N)(what, __VA_ARGS__)
|
wxCONCAT(wxCALL_FOR_EACH_, N) args
|
||||||
|
|
||||||
#define wxCALL_FOR_EACH(what, ...) \
|
#define wxCALL_FOR_EACH(what, ...) \
|
||||||
wxCALL_FOR_EACH_(wxCALL_FOR_EACH_NARG(__VA_ARGS__), what, __VA_ARGS__)
|
wxCALL_FOR_EACH_(wxCALL_FOR_EACH_NARG(__VA_ARGS__), (what, __VA_ARGS__))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define wxCALL_FOR_EACH Error_wx_CALL_FOR_EACH_requires_variadic_macros_support
|
#define wxCALL_FOR_EACH Error_wx_CALL_FOR_EACH_requires_variadic_macros_support
|
||||||
|
Reference in New Issue
Block a user