Reputation: 11
I keep getting this compilation error:
error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token
on the marked line below:
//128 bit vector struct (4 integers)
typedef struct {
int w, x, y, z;
} iVector4;
iVector4 SSEadd(iVector4 &v1, iVector4 &v2) // <-- this line
{
iVector4 vr;
asm
{
MOV EAX v1
MOV EBX v2
//
MOVUPS XMM0, [EAX]
MOVUPS XMM1, [EBX]
//
PADDD XMM0 XMM1
MOVUPS [rv]
}
return rv;
}
I really can't see what's wrong: What seems to be the problem?
EDIT:
Hi thanks for all the responses.
I'm using gcc as a compiler, and I realize that the assembly code that I had provided was also incorrect.I was wondering if its best to use the built_in functions from -msse/-msse2.
Also, what's the most efficient way to load and extract values from a vector such as v4si?
I'm finding that loading and extracting from the vector is a costly ooperation.
When you say sse intrinsics, what exactly did you mean?
Thanks for all the help.
Upvotes: 1
Views: 144
Reputation: 2933
You also might want to consider using SSE intrinsics instead of what it looks like you're doing.
Upvotes: 1
Reputation: 77762
C doesn't have references. You should use a pointer instead, or use C++.
iVector4 SSEadd(iVector4 *v1, iVector4 *v2)
Now the next question - can you return objects in C? My C is rusty. If that's the not case, you'd need:
void SSEadd(iVector4 *v1, iVector4 *v2, iVector4 *vOut)
EDIT: As Justin pointed out, it is possible, so you don't need to go that route. You still could though - depending on the circumstances, it could be more performant.
Upvotes: 4
Reputation: 8125
I think your function definition should actually be:
iVector4 SSEadd(iVector4 *v1, iVector4 *v2);
Upvotes: 1
Reputation: 61643
C does not have references. You need to compile as C++ for those.
Upvotes: 7