我遇到了涉及可变参数宏的代码,我想知道这意味着什么
#define DECLARE_LEGACY_TYPES(...) //This all of the macro - I am not holding out on anything
Run Code Online (Sandbox Code Playgroud)
现在有这个类
Header file: .h
namespace LG_Wrapper
{
template <LG_Thread Thread>
class EffectApplication : public ktApplication
{
public:
static EffectApplication<Thread>& GetInstance();
protected:
.....
.....
static boost::recursive_mutex mResource;
}
}
DECLARE_LEGACY_TYPES(EffectApplication); <---- What does this do ?
Run Code Online (Sandbox Code Playgroud)
我想知道宏有什么影响?
更新: 我收到了很多关于此的问题,因为这个问题给人的印象是我没有发布宏的全部内容.宏没有更多内容了.我希望有.这个问题是有关本该被关闭.这个宏字面上刚刚结束(...)
#define DECLARE_LEGACY_TYPES(...)
Run Code Online (Sandbox Code Playgroud)
但是没有.这就是我在这里的原因之一,因为我不知道如何处理这种情况.这个宏有效吗?
更多信息:
这是我在另一个文件中使用的,我在项目设置中使用以下定义
LG_WRAPPER_EXPORTS
LG_THREAD_NAME=GAME
Run Code Online (Sandbox Code Playgroud)
以下是代码
namespace LG_Wrapper
{
enum LG_Thread
{
GAME,
OTHER
};
/*
If the library itself is including this file
*/
#ifdef LG_WRAPPER_EXPORTS
#ifndef LG_THREAD_NAME
#error You must define LG_THREAD_NAME!
#endif
//Legacy types should not be used internally
#define DECLARE_LEGACY_TYPES(...)
#else // LG_WRAPPER_EXPORTS
//Legacy typenames are provided for convenience to the client
#define DECLARE_LEGACY_TYPES(ClassType) \
typedef LG_Wrapper::##ClassType##<LG_Wrapper::GAME> ClassType; \
#endif // LG_WRAPPER_EXPORTS
}
Run Code Online (Sandbox Code Playgroud)
这实际上很常见,但它取决于您查看的其他代码中未提及的其他代码:
#if USING_OLD_COMPILER //when using an older compiler, use this to declare legacy types
#define DECLARE_LEGACY_TYPES(...) STUFF(__VA_ARGS__)
#else //new compiler doesn't have to do anything special
#define DECLARE_LEGACY_TYPES(...)
#endif
//in older compilers we had to declare legacy types for this
//newer compilers don't need this step, so this does nothing at all in them.
DECLARE_LEGACY_TYPES(EffectApplication);
Run Code Online (Sandbox Code Playgroud)
我实际上并不知道这个宏,所以我不知道它的实际用途.但是,通常会看到没有类似技巧定义的宏.