Flo Flo - 16 days ago 6
C Question

error: expected primary-expression before ')' token (C)

I am trying to call a function named

characterSelection(SDL_Surface *screen, struct SelectionneNonSelectionne sel)
which returns a
void


This is the
.h
of the function I try to call:

struct SelectionneNonSelectionne;
void characterSelection(SDL_Surface *screen, struct SelectionneNonSelectionne);
void resetSelection(SDL_Surface *screen, struct SelectionneNonSelectionne);


On my main function, I try to call it like this:

characterSelection(screen, SelectionneNonSelectionne);


When I compile, I have the message:

error: expected primary-expression before ')' token


I made the
includes
. I suppose I miscall the second argument, my
struct
. But, I can't find why on the net.

Have you got any idea about what I did wrong ?

Answer

You should create a variable of the type SelectionneNonSelectionne.

struct SelectionneNonSelectionne var;

After that pass that variable to the function like

characterSelection(screen, var);

The error is caused since you are passing the type name SelectionneNonSelectionne

Comments