读书人

问一个关于MAX函数64位上编译的有关问

发布时间: 2012-11-01 11:11:32 作者: rapoo

问一个关于MAX函数64位下编译的问题
我用的是VC2005 +SP1 win7 64bit

std::max(m_iMaxStackSize, m_iStackPos)函数的参数分别是 size_t 和 unsigned int两种类型的,32位编译没任何问题,也没有警告,64位报错如下

1>.\muParserBytecode.cpp(255) : error C2780: 'const _Ty &std::max(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2 provided
1> C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xutility(3190) : see declaration of 'std::max'
1>.\muParserBytecode.cpp(255) : error C2782: 'const _Ty &std::max(const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous
1> C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xutility(3182) : see declaration of 'std::max'
1> could be 'unsigned int'
1> or 'size_t

请问除了把unsigned int参数强制转换为size_t类型外,还有没有更好的解决办法? 谢谢大家.

[解决办法]
x64下 分别sizeof(size_t) sizeof(unsigned int)看看,大小应该不一样。
最好用MAX宏
[解决办法]
size_t 64位下是8字节。
unsigned int 是4字节。

读书人网 >VC/MFC

热点推荐