Skip to content

Commit

Permalink
[WIP] Fix macro va_args counter macros for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
vigsterkr committed Sep 24, 2016
1 parent 989418f commit a20b4fa
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/shogun/base/SGObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,21 @@ template <class T> class SGStringList;
* Macros for registering parameters/model selection parameters
******************************************************************************/

#ifdef _MSC_VER

#define VA_NARGS(...) INTERNAL_EXPAND_ARGS_PRIVATE(INTERNAL_ARGS_AUGMENTER(__VA_ARGS__))
#define INTERNAL_ARGS_AUGMENTER(...) unused, __VA_ARGS__
#define INTERNAL_EXPAND(x) x
#define INTERNAL_EXPAND_ARGS_PRIVATE(...) INTERNAL_EXPAND(INTERNAL_GET_ARG_COUNT_PRIVATE(__VA_ARGS__, 5, 4, 3, 2, 1, 0))
#define INTERNAL_GET_ARG_COUNT_PRIVATE(_0_, _1_, _2_, _3_, _4_, _5_, count, ...) count

#else

#define VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1)

#endif

#define VARARG_IMPL2(base, count, ...) base##count(__VA_ARGS__)
#define VARARG_IMPL(base, count, ...) VARARG_IMPL2(base, count, __VA_ARGS__)
#define VARARG(base, ...) VARARG_IMPL(base, VA_NARGS(__VA_ARGS__), __VA_ARGS__)
Expand Down Expand Up @@ -431,7 +443,7 @@ class CSGObject
/** Registers a class parameter which is identified by a tag.
* This enables the parameter to be modified by set() and retrieved by get().
* Parameters can be registered in the constructor of the class.
*
*
* @param _tag name and type information of parameter
* @param value value of the parameter
*/
Expand Down Expand Up @@ -509,7 +521,7 @@ class CSGObject
* @param any value without type information of the parameter
*/
void set_with_base_tag(const BaseTag& _tag, const Any& any);

/** Getter for a class parameter, identified by a BaseTag.
* Throws an exception if the class does not have such a parameter.
*
Expand Down

0 comments on commit a20b4fa

Please sign in to comment.