SetSlapShot
SetSlapShot

Reputation: 1298

called object not a function c

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?

Upvotes: 0

Views: 2869

Answers (3)

Steve M
Steve M

Reputation: 8516

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.

Upvotes: 1

Ryan
Ryan

Reputation: 1797

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

Rename PFrame copyFrame to something else and it should work.

Upvotes: 0

user7116
user7116

Reputation: 64068

You've redefined copyFrame in that local scope:

PFrame copyFrame = prep->first;

Upvotes: 6

Related Questions