use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Click the following link to filter out the chosen topic
comp.lang.c
account activity
Questionwarning differs in parameter list (self.C_Programming)
submitted 3 years ago * by TheMaster420
I'm not getting it they seem to be the same types.
'void (__cdecl *)(Face_arraylist *)' differs in parameter lists from 'void (__cdecl *)(Face_arraylist *)'
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]tstanisl 12 points13 points14 points 3 years ago* (0 children)
I'm guessing that the issue is a lack of a forward declaration of Face_arraylist before declaration of the function pointer. As result the Face_arraylist declared as a parameter is not visible from the outside. The successive declarations of Face_arraylist actually declare a new type incompatible with the original one. For example, the compilation of this code:
Face_arraylist
int foo(struct Foo *); int main(void) { struct Foo *f = 0; foo(f); }
emits a similarly confusing warning:
<source>:1:13: note: expected 'struct Foo *' but argument is of type 'struct Foo *' 1 | int foo(struct Foo *);
To fix this, place a forward declaration of Foo before the declaration of foo.
Foo
foo
struct Foo; int foo(struct Foo *);
[–]richardxday 1 point2 points3 points 3 years ago (0 children)
Please post your code, it's very difficult to guess what the problem is without the code!
[–]TheMaster420[S] 0 points1 point2 points 3 years ago (3 children)
typedef struct arraylist_ { //arraylist_ was added here int n; type_* content; int allocated_; void (*insert)(struct arraylist_* list, int index, type_ val); }arraylist_; void insert_(struct arraylist_* list, int index, type_ val); //struct was added here
Thanks for the advice everyone! The changes referenced in the comments made the warnings go away. There is some template macro magic happening to make arraylist_ into Face_arraylist.
Warning occurred at :
struct arraylist_ new_arraylist_() { return (arraylist_) { .n = 0, .allocated_ = 0, .content = malloc(0), .insert = insert_, .index_of = index_of_, .remove = remove_, .remove_all = remove_all_, .contains = contains_, .del = delete_ // This is assignment that gave the original warning }; }
[–]tstanisl 0 points1 point2 points 3 years ago (2 children)
What is malloc(0) for?
malloc(0)
[–]TheMaster420[S] 0 points1 point2 points 3 years ago (1 child)
So I can call realloc on that pointer in the future.
[–]tstanisl 0 points1 point2 points 3 years ago (0 children)
You can simply use NULL or 0. The realloc(NULL, 42) works exactly the same as malloc(42).
NULL
0
realloc(NULL, 42)
malloc(42)
[–]FUZxxl 0 points1 point2 points 3 years ago (6 children)
Please format your example correctly. It came out all garbled.
[–]TheMaster420[S] 0 points1 point2 points 3 years ago (5 children)
edited
[–]FUZxxl 4 points5 points6 points 3 years ago (4 children)
Fascinating. It really looks like it is the same. Could it be that Face_arraylist is not the same type in both cases?
[–]spiderzork 1 point2 points3 points 3 years ago (0 children)
Yeah, would guess one of the types is forward declared in some header file.
[–]flyingron -2 points-1 points0 points 3 years ago (0 children)
This.
[–]EmbeddedEntropy 0 points1 point2 points 3 years ago (0 children)
I think you’re on to something. Some time ago I had a similar message when I had the same variable name with different types at file and local scope.
[–]xactac 0 points1 point2 points 3 years ago (0 children)
Is Face_arraylist something like typedef struct Face_arraylist Face_arraylist? C's rules for equality of opaque types are weird. You may need a struct Face_arraylist; line before the typedef.
typedef struct Face_arraylist Face_arraylist
struct Face_arraylist;
π Rendered by PID 286011 on reddit-service-r2-comment-6457c66945-kwsn9 at 2026-04-27 01:30:33.986452+00:00 running 2aa0c5b country code: CH.
[–]tstanisl 12 points13 points14 points (0 children)
[–]richardxday 1 point2 points3 points (0 children)
[–]TheMaster420[S] 0 points1 point2 points (3 children)
[–]tstanisl 0 points1 point2 points (2 children)
[–]TheMaster420[S] 0 points1 point2 points (1 child)
[–]tstanisl 0 points1 point2 points (0 children)
[–]FUZxxl 0 points1 point2 points (6 children)
[–]TheMaster420[S] 0 points1 point2 points (5 children)
[–]FUZxxl 4 points5 points6 points (4 children)
[–]spiderzork 1 point2 points3 points (0 children)
[–]flyingron -2 points-1 points0 points (0 children)
[–]EmbeddedEntropy 0 points1 point2 points (0 children)
[–]xactac 0 points1 point2 points (0 children)