1
我遇到了这个代码,涉及复杂的宏,我想知道这是什么意思复杂的宏
#define DECLARE_LEGACY_TYPES(...) //This all of the macro - I am not holding out on anything
现在有这个类,因为这
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 ?
我想知道什么影响宏有?
更新: 我收到了很多关于此的问题,因为这个问题给人留下的印象是我没有发布宏的全部内容。没有什么更多的宏观。我希望有。此问题与已关闭的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
}
它只是在这里跳过一些无用的东西。 –
可以将#define与“...”一起使用吗?似乎在那里有一些缺失。 – AlainD
@AlainD:是的,可变宏。 https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html但是这个扩展到完全没有。 –