called object not a function c

拜拜、爱过 提交于 2019-12-25 00:17:34

问题


Good morning SO- this ones been cooking my noodle for a bit (also, it's very hard to google about the c programming language I've noticed...)

void prepareFrames(PDouble prep){
  int gap = prep->gap;
  printf("Gap is %d\n", gap);
  prep->intFrames = (PFrame*)malloc(gap*sizeof(PFrame));
  PFrame copyFrame = prep->first;
  int i;
  for(i=0; i < gap; i++){
    prep->intFrames[i] = (PFrame)malloc(sizeof(Frame));
    copyFrame(prep->intFrames[i], prep->first, i);          //LINE 189
  }
}

void copyFrame(PFrame new, PFrame copy, int num){
  new->sequence = copy->sequence;
  new->evaluatedFrame = copy->evaluatedFrame + num;
  new->numBoxes = copy->numBoxes;
  new->boxes = (PBox*)malloc(copy->numBoxes*sizeof(PBox));
  int i;
  for(i=0; i < copy->numBoxes; i++){
    PBox old = copy->boxes[i];
    new->boxes[i] = (PBox)malloc(sizeof(Box));
    copyBox(new->boxes[i], old);
  }
}

And I'm getting this error:

error: called object ‘copyFrame’ is not a function

The prototypes match the definition. What gives?


回答1:


You've redefined copyFrame in that local scope:

PFrame copyFrame = prep->first;



回答2:


You've defined a local variabe named copyFrame: PFrame copyFrame = prep->first; Unless PFrame is defined by

typedef void (*PFrame)(PFrame new, PFrame copy, int num);

I don't see how it should ever compile. Otherwise, you don't even use that copyFrame variable.




回答3:


You have a variable named copyFrame which is conflicting with your function name.

Rename PFrame copyFrame to something else and it should work.



来源:https://stackoverflow.com/questions/10949982/called-object-not-a-function-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!