Reputation: 3959
I have the following piece of code:
typedef struct Folder{
void (**vtable)();
struct Set *ns;
}Folder;
Node *newFolder(char *n,struct Set *ns);
When I compile this file, it gives me:
passing argument to parameter 'ns' here
Node *newFolder(char *n,struct Set *ns);
Here is my test unit for this:
void testFolderNrNodes(CuTest *tc) {
Node_reset();
Node* folder = newFolder("folder_to_test", SetNil());
CuAssertIntEquals(tc, 1, nrNodes(folder));
}
which gives me this error:
incompatible integer to pointer conversion passing 'int' to parameter of type
'struct Set *' [-Wint-conversion]
Node* folder = newFolder("folder_to_test", SetNil());
^~~~~~~~
I don't see what the problem is. Does it come from the struct Set *ns
? Why do I get this message with "incompatible integer to pointer conversion passing 'int' to parameter of type 'struct Set *"
?
Can someone please let me know what I am doing wrong?
Upvotes: 0
Views: 20391
Reputation: 1432
From your comment, it is clear that the SetNil()
is indeed returning an int. If you really want to avoid the warning then you can change the code to
newFolder("folder_to_test", (struct Set *)SetNil())
However, that could be really dangerous, unless you can know what SetNil returns. The real fix should be in the function SetNil()
Upvotes: 0
Reputation: 25179
Your SetNil()
function either returns an integer or has not been declared before its use (in which case the compiler will assume it returns an integer). newFolder()
however is expecting its second parameter to be a struct Set *
.
Upvotes: 1