编译x64平台时出现c2593错误(操作员标识符不明确)

时间:2022-09-01 10:18:14

I'm trying to compile a C++ project using Microsoft VisualStudio 2008. This particular project compiles fine if you use Win32 as target platform. If I try to compile the same project for the x64 platform I get a C2593 'operator identifier' is ambiguous error in this line:

我正在尝试使用Microsoft VisualStudio 2008编译C ++项目。如果您使用Win32作为目标平台,此特定项目编译良好。如果我尝试为x64平台编译相同的项目,我得到一个C2593'运算符标识'在这一行中是一个模糊的错误:

case 't':  os_ << (size_t)path->rnode->char_type;     break;

Anyone has a clue why the same line compiles fine for 32-bit but fails for 64-bit with such a high level error?

任何人都有一个线索,为什么同一行编译为32位罚款,但64位失败,如此高水平的错误?

1 个解决方案

#1


Ok, got it. The problem is the size_t data type which has different sizes for the two different plattforms. The operator << is defined for a various list of data types:

好的,我知道了。问题是size_t数据类型,它对于两个不同的平台具有不同的大小。 operator < <是为各种数据类型列表定义的:< p>

StringBuffer& operator<<(unsigned short int n) { _UITOA(n); }
StringBuffer& operator<<(unsigned int n)       { _UITOA(n); }

On a 32-bit platform "unsigned int" is a perfect match for size_t. On 64-bit platforms size_t is 64 bits and doesn't match exactly on any operator declaration.

在32位平台上,“unsigned int”是size_t的完美匹配。在64位平台上,size_t是64位,并且在任何运算符声明上都不完全匹配。

The solution is to choose the exact operator by using the correct data type:

解决方案是使用正确的数据类型选择确切的运算符:

case 't':  os_ << (unsigned int)path->rnode->char_type;     break;

Or overload the operator using size_t:

或使用size_t重载运算符:

StringBuffer& operator<<(size_t)       { _UITOA(n); }

#1


Ok, got it. The problem is the size_t data type which has different sizes for the two different plattforms. The operator << is defined for a various list of data types:

好的,我知道了。问题是size_t数据类型,它对于两个不同的平台具有不同的大小。 operator < <是为各种数据类型列表定义的:< p>

StringBuffer& operator<<(unsigned short int n) { _UITOA(n); }
StringBuffer& operator<<(unsigned int n)       { _UITOA(n); }

On a 32-bit platform "unsigned int" is a perfect match for size_t. On 64-bit platforms size_t is 64 bits and doesn't match exactly on any operator declaration.

在32位平台上,“unsigned int”是size_t的完美匹配。在64位平台上,size_t是64位,并且在任何运算符声明上都不完全匹配。

The solution is to choose the exact operator by using the correct data type:

解决方案是使用正确的数据类型选择确切的运算符:

case 't':  os_ << (unsigned int)path->rnode->char_type;     break;

Or overload the operator using size_t:

或使用size_t重载运算符:

StringBuffer& operator<<(size_t)       { _UITOA(n); }