在C++中执行SSE时编译错误
我的代码对于理解SSE来说非常简单。我的代码是:
#include <iostream>
#include <iomanip>
#include <xmmintrin.h>
using namespace std;
struct cVector {
float x,y,z; };
int main()
{
cVector vec1;
vec1.x=0.5;
vec1.y=1.5;
vec1.z=-3.141;
__asm
{
movups xmm1, vec1
mulps xmm1, xmm1
movups vec1, xmm1
}
cout << vec1.x << " " << vec1.y << " " << vec1.z << '\n';
return 0;
}
我使用的是Ubuntu 10.04。为了编译,我使用了以下命令:
$ gcc -o program -msse -mmmx -msse2 sse.cpp
我发现以下错误:
sse.cpp: In function ‘int main()’:
sse.cpp:20: error: expected ‘(’ before ‘{’ token
sse.cpp:21: error: ‘movups’ was not declared in this scope
sse.cpp:21: error: expected ‘;’ before ‘xmm1’
任何人都可以帮助我如何删除此错误?
My code is very simple for understanding SSE. My code is:
#include <iostream>
#include <iomanip>
#include <xmmintrin.h>
using namespace std;
struct cVector {
float x,y,z; };
int main()
{
cVector vec1;
vec1.x=0.5;
vec1.y=1.5;
vec1.z=-3.141;
__asm
{
movups xmm1, vec1
mulps xmm1, xmm1
movups vec1, xmm1
}
cout << vec1.x << " " << vec1.y << " " << vec1.z << '\n';
return 0;
}
I am using Ubuntu 10.04. for compilation i used the following command:
$ gcc -o program -msse -mmmx -msse2 sse.cpp
The following error I found:
sse.cpp: In function ‘int main()’:
sse.cpp:20: error: expected ‘(’ before ‘{’ token
sse.cpp:21: error: ‘movups’ was not declared in this scope
sse.cpp:21: error: expected ‘;’ before ‘xmm1’
Can anyone please help me how can I remove this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要尝试使用内联汇编来做到这一点 - 使用提供的内在函数,例如
Don't try to do this with inline asm - use the provided intrinsics, e.g.