编译器重复定义错误:error C2371: 'SIZE' : redefinition; different basic types

时间:2023-03-09 03:06:49
编译器重复定义错误:error C2371: 'SIZE' : redefinition; different basic types

我们常常会定义自己工程用的数据类型,可能会与Windows的基本数据类型冲突。

vs会报重复定义错误:error C2371: 'SIZE' : redefinition; different basic types

解决方法:欺骗编译器

#define SIZE wSIZE
typedef long SIZE;
#undef SIZE
typedef int SIZE; int _tmain(int argc, _TCHAR* argv[])
{
SIZE n = 0; //SIZE = int
wSIZE wN = 0; //wSIZE = long return 0;
}