plugincpp
plugincpp copied to clipboard
fix __VA_ARGS__ on windows unfold error and register_handler name error
__VA_ARGS__在windows上visual studio上不能正确展开,只能被识别为一个参数。 1)可以在cmake中添加set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:preprocessor"),但是会带来一些警告。 2)通过宏#define EXPAND( ... ) __VA_ARGS__再转一层可以解决。
template<typename Self, typename Function>
int register_handler(Self&& self, std::string const& name, const Function& f) {
register_handler(name, f, &self);
return 0;
}
register_handler(name, f, &self);会导致name少了首字母