define ICPU(model) { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
可以当做是自定义的数据模型,可以当做数组但是不能用数组方式调用,可以当做结构体用来为结构体赋值,等等。
比如:
#include <stdio.h>
#define X86_VENDOR_INTEL 100
#define X86_FEATURE_ANY 1000
#define CORE_I_3 1
#define CORE_I_5 2
#define CORE_I_7 3
//定义数据模型
#define ICPU(model) { X86_VENDOR_INTEL, 2016, model, X86_FEATURE_ANY, }
//定义结构体
struct CPUID {
int name;
int year;
int cpu_name;
int feature;
};
//采用上述数据模型为结构体数组复制
static const struct CPUID cpuid[] = {
ICPU(CORE_I_3),
ICPU(CORE_I_5),
ICPU(CORE_I_7),
};
int main() {
for (size_t i = 0; i < 3; i++)
{
if (cpuid[i].cpu_name == CORE_I_3) {
printf("i3 cpu \n");
}
else if (cpuid[i].cpu_name == CORE_I_5)
{
printf("i5 cpu \n");
}
else
{
printf("i7 cpu \n");
}
}
printf("test! \n");
system("pause");
return 0;
}
good luck !