可变参数宏
Variadic Macros
我看到这段代码涉及可变参数宏,我想知道那是什么意思
#define DECLARE_LEGACY_TYPES(...) //This all of the macro - I am not holding out on anything
现在有这个class作为这个
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 ?
我想知道这个宏有什么作用?
更新:
我收到了很多反对票,因为这个问题给人的印象是我没有 post 宏的全部内容。没有更多的宏。我希望有。此问题与已关闭的 this 有关。宏字面意思是在 (...)
之后结束
#define DECLARE_LEGACY_TYPES(...)
但是没有。这就是我来这里的原因之一,因为我不确定如何处理这种情况。那么这个宏是不是没有作用了?
更多信息:
这是我在另一个文件中的内容
我正在使用我的项目设置中定义的以下内容
LG_WRAPPER_EXPORTS
LG_THREAD_NAME=GAME
代码如下
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
}
这实际上很常见,但它取决于您查看的其他代码中未提及的其他代码:
#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);
我实际上并不知道这个宏,所以我不知道它的实际用途。但是,对于与此类似的技巧,经常会看到没有定义的宏。
我看到这段代码涉及可变参数宏,我想知道那是什么意思
#define DECLARE_LEGACY_TYPES(...) //This all of the macro - I am not holding out on anything
现在有这个class作为这个
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 ?
我想知道这个宏有什么作用?
更新: 我收到了很多反对票,因为这个问题给人的印象是我没有 post 宏的全部内容。没有更多的宏。我希望有。此问题与已关闭的 this 有关。宏字面意思是在 (...)
之后结束 #define DECLARE_LEGACY_TYPES(...)
但是没有。这就是我来这里的原因之一,因为我不确定如何处理这种情况。那么这个宏是不是没有作用了?
更多信息:
这是我在另一个文件中的内容 我正在使用我的项目设置中定义的以下内容
LG_WRAPPER_EXPORTS
LG_THREAD_NAME=GAME
代码如下
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
}
这实际上很常见,但它取决于您查看的其他代码中未提及的其他代码:
#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);
我实际上并不知道这个宏,所以我不知道它的实际用途。但是,对于与此类似的技巧,经常会看到没有定义的宏。