我使用include定义了一个枚举,因为有不同的枚举具有相同的枚举数据,我想重用它:
#define X(SYM) SYM
#define X_INIT(SYM,VAL) SYM = VAL
/// Destination for scalar memory read instruction
enum SSRC
{
#include "GenericInstructionFields1.h"
#include "ScalarInstructionFields.h"
#include "GenericInstructionFields2.h"
};
enum SDST
{
#include "GenericInstructionFields1.h"
};
#undef X_INIT
#undef X
};
但我无法编译 SDST 的代码。编译器为来自“GenericInstructionFields1.h”的 SSRC 字段编写重新定义。问题的原因是什么,如何解决?
//GenericInstructionFields1.h
/// SGPR0 to SGPR103: Scalar general-purpose registers.
X_INIT(ScalarGPRMin,0),
X(ScalarGPR),
X_INIT(ScalarGPRMax,103),
/// 104 – 105 reserved.
X(Reserved104),
X(Reserved105),
X_INIT(Reserved,2),
/// vcc[31:0].
X_INIT(VccLo, 106),
/// vcc[63:32].
X(VccHi),