Work around bugs in Visual C++ variadic macro parsing and/or non-standard use of same. Compiles on win32 and linux, whether it works is anyone's guess.

This commit is contained in:
Eric Frias 2014-06-10 09:56:58 -04:00
parent 51de9e6abf
commit f034839f10
2 changed files with 8 additions and 4 deletions

View file

@ -297,10 +297,12 @@ namespace fc
do { throw EXCEPTION_TYPE( FC_LOG_MESSAGE( error, "", FC_FORMAT_ARG_PARAMS(__VA_ARGS__) ) ); } while(false);
//#define FC_THROW( FORMAT, ... )
// FC_INDIRECT_EXPAND workas around a bug in Visual C++ variadic macro processing that prevents it
// from separating __VA_ARGS__ into separate tokens
#define FC_INDIRECT_EXPAND(MACRO, ARGS) MACRO ARGS
#define FC_THROW( ... ) \
do { \
throw fc::exception( FC_LOG_MESSAGE( error, __VA_ARGS__ ) ); \
throw fc::exception( FC_INDIRECT_EXPAND(FC_LOG_MESSAGE, ( error, __VA_ARGS__ )) ); \
} while(0)
#define FC_EXCEPTION( EXCEPTION_TYPE, FORMAT, ... ) \

View file

@ -131,8 +131,10 @@ namespace fc
#define FC_FORMAT( SEQ )\
BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARG, v, SEQ )
#define FC_FORMAT_ARG_PARAMS( SEQ )\
BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARGS, v, SEQ )
// takes a ... instead of a SEQ arg because it can be called with an empty SEQ
// from FC_CAPTURE_AND_THROW()
#define FC_FORMAT_ARG_PARAMS( ... )\
BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARGS, v, __VA_ARGS__ )
#define idump( SEQ ) \
ilog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )