I am trying to call a function named characterSelection(SDL_Surface *screen, struct SelectionneNonSelectionne sel)
which returns a void
我正在尝试调用一个名为characterSelection(SDL_Surface *screen, struct SelectionneNonSelectionne sel)的函数,它返回一个void。
This is the .h
of the function I try to call:
这是函数的。h函数
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 ?
你知道我做错了什么吗?
3 个解决方案
#1
10
You should create a variable of the type SelectionneNonSelectionne.
您应该创建类型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
错误是由于您传递类型名称SelectionneNonSelectionne而引起的。
#2
2
You're passing a type as an argument, not an object. You need to do characterSelection(screen, test);
where test is of type SelectionneNonSelectionne
.
您将类型作为参数传递,而不是对象。您需要进行字符选择(屏幕、测试);在测试的类型为SelectionneNonSelectionne。
#3
1
A function call needs to be performed with objects. You are doing the equivalent of this:
函数调用需要用对象来执行。你所做的相当于这个:
// function declaration/definition
void foo(int) {}
// function call
foo(int); // wat!??
i.e. passing a type where an object is required. This makes no sense in C or C++. You need to be doing
即传递需要对象的类型。这在C或c++中没有意义。你需要去做。
int i = 42;
foo(i);
or
或
foo(42);
#1
10
You should create a variable of the type SelectionneNonSelectionne.
您应该创建类型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
错误是由于您传递类型名称SelectionneNonSelectionne而引起的。
#2
2
You're passing a type as an argument, not an object. You need to do characterSelection(screen, test);
where test is of type SelectionneNonSelectionne
.
您将类型作为参数传递,而不是对象。您需要进行字符选择(屏幕、测试);在测试的类型为SelectionneNonSelectionne。
#3
1
A function call needs to be performed with objects. You are doing the equivalent of this:
函数调用需要用对象来执行。你所做的相当于这个:
// function declaration/definition
void foo(int) {}
// function call
foo(int); // wat!??
i.e. passing a type where an object is required. This makes no sense in C or C++. You need to be doing
即传递需要对象的类型。这在C或c++中没有意义。你需要去做。
int i = 42;
foo(i);
or
或
foo(42);