-1
我只是用一个系统上的代码没有完整的内存管理
的左操作数:铸造:左值要求作为分配
typedef unsigned short component_t;
typedef struct {
component_t* c; // least-significant word first
unsigned int num_components; // number of unsigned short rows
} integer;
integer result;
result.c=malloc(component_t*)malloc(sizeof(component_t)*128); //this is just an example to tell I'm correctly initializing. There's no malloc nor memset inside OpenCL. currently, I'm trying to speed up the code serially before switching to OpencL. That's also why I don't use GMP.
result.num_components=128
下一行:
for(int i=0;i<result.num_components/4;i++) (unsigned long)result.c[i] = 26; // assign 26 in that part of the memory
触发:
gcc integer.c
integer.c:567:36 error: lvalue required as left operand of assignment
(unsigned long)result.c[5] = 26;
^
我不知道这条线的真正问题,以及我需要写些什么来纠正这个问题。
注:我也看到(即使这是没用的)是:
for(int i=0;i<result.num_components/4;i++) (unsigned long)result.c[i]++
编译而
没有。
'result.c =的malloc(component_t *)malloc的(...':不幸的复制/粘贴 –
你是什么?试图完全实现?只是因为你编译器错误消失并不意味着代码将工作:) –
@NisseEngström:没有。 – user2284570