Error: Calling a host function from a global function


I’m getting this error while building solution : " error: calling a host function (“operator+”) from a device / global function (“TwoPoint”) is not allowed "

I tried everything on Internet. What is the problem? Is there any nobody who can help me? I’m using VS 2010 and Windows 7 with Cuda 4.0

This is code:

inline float2 operator+(float2 A, float2 B){float2 C; C.x=A.x+B.x; C.y=A.y+B.y; Return C;}

inline __device__ void TwoPoint(float2 &A, float2 &B)


  float2 temp = B;

  B = A+B;

  A = temp;


Declare the operator as a device function.

Thank you very much It worked :laugh: