同じ列挙データを持つ異なる列挙型があり、それを再利用したいので、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),