Add macro to help pass commas into other macros.

VTKM_PASS_COMMAS(...) will pass it's arguments verbatim into another
macro, even if they contain commas. This is helpful when using templated
classes, e.g.

#define SOME_MACRO(arg) ...

SOME_MACRO(vtkm::cont::ArrayHandle<float, StorageTag>)

won't compile, because the comma in the template parameters is assumed
to be separating macro arguments. Adding extra parenthesis,

SOME_MACRO((vtkm::cont::ArrayHandle<float, StorageTag>))

helps in some cases, but not others (e.g. the macro declares a variable).

SOME_MACRO(VTKM_PASS_COMMAS(vtkm::cont::ArrayHandle<float, StorageTag>))

will always* work.
This commit is contained in:
David C. Lonie 2017-06-22 15:40:32 -04:00
parent d4d7683f17
commit bc1b920741

@ -294,6 +294,11 @@
while (false)
#endif
// Use a trick to pass arguments containing commas through a macro. This is
// helpful for mixing template code with macros.
// See https://stackoverflow.com/questions/13842468
#define VTKM_PASS_COMMAS(...) __VA_ARGS__
#ifdef VTKM_MSVC
//With MSVC the types that we generate cause warning C4503 (long symbol names)
//this doesn't affect the resulting binary so we just supress that warning