您的位置:首页 > 其它

vs2005转换到vs2012嵌入汇编出现如下错误error C2244

2017-03-28 13:09 204 查看
问题

1>------ 已启动生成: 项目: sage_capture_final, 配置: Debug Win32 ------
1> sage_capture_final_Part.cpp
1>sage_capture_final_Part.cpp(1871): error C2244: “std::end”: 无法将函数定义与现有的声明匹配
1>sage_capture_final_Part.cpp(1871): error C2415: 不正确的操作数类型
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========


代码
int GetSystemBit()
{
int i=0;
int x=0;
double a=0;
__asm //将-1 连续左移直到为 0
{
mov eax,-1; //将-1赋值给eax
start:
cmp eax,0; //判断 eax - 0 ?= 0
je end; //以上两个值相等则跳转end

shl eax,1; //左移一位
mov ecx,i; //将i赋值给ecx
inc ecx; //将ecx增加1
mov i,ecx; //将ecx赋值给i
jmp start; //跳转到 start
end:
mov x,eax;
}
return i;
}

解决方法
重命名end即可,如下列代码所示

int GetSystemBit()
{
int i=0;
int x=0;
double a=0;
__asm //将-1 连续左移直到为 0
{
mov eax,-1; //将-1赋值给eax
start:
cmp eax,0; //判断 eax - 0 ?= 0
je end2; //以上两个值相等则跳转end

shl eax,1; //左移一位
mov ecx,i; //将i赋值给ecx
inc ecx; //将ecx增加1
mov i,ecx; //将ecx赋值给i
jmp start; //跳转到 start
end2:
mov x,eax;
}
return i;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐