error: no operator "=": volatile Struct1= Struct1 volatile

Hi Guys,

How to solve below error? Struct1 can’t be such as int2. Only int works. Thanks!


f(Stuct1 d_data,...)


volatile __shared__ Struct1 s;


s = d_data[i];



error: no operator “=” matches these operands

 operand types are: volatile Struct1= Struct1

You can’t assign one struct to another. You need to use one of the Memcpy variants, just like in plain old C programming.

If your struct has pointers, you’ll also need to decide if you want the copy to point to the original data or if you need to make a copy of the data being pointed to (which is one of the reasons you can’t just assign one struct to another).

Thanks! i can do s = d_data[i] if removing the “volatile” keyword, i.e., shared Struct1 s. so, got to learn about volatile:) Thanks!