GCC 3.4.5 (MinGW version) produces a warning: parameter has incomplete type for line 2 of the following C code:
struct s;
typedef void (* func_t)(struct s _this);
struct s { func_t method; int dummy_member; };
Is there a way to fix this (or at least hide the warning) without changing the method argument's signature to (struct s *)?
Note:
As to why something like this would be useful: I'm currently tinkering with an object-oriented framework; 'method' is an entry in a dispatch table and because of the particular design of the framework, it makes sense to pass '_this' by value and not by reference (as it is usually done)...
You want to call it with a function pointer. Why not use a void pointer instead?
You MIGHT be able to pass a loosely-typed function pointer as well; I don't have a compiler on hand.
The warning seems to be a bug with the current MinGW version of gcc. Contrary to what Adam said, it is valid C99 - section 6.7.5.3, paragraph 12 explicitly allows this:
There seems to be no way to instruct (this version of) gcc to not print this warning - at least I could not find a switch which worked - so I'm just ignoring it for now.
Hiding warnings is generally pretty easy - just look at the help for your particular compiler.
http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gcc/index.html#//apple_ref/doc/uid/TP40001838
Note that suppressing warnings is generally not something I would advocate.
Switching to GCC 4 seems like it should work. MinGW version 4.3.0: http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=241304&release_id=596917
You can't quite do this easily - according to the C99 standard, Section 6.7.5.3, paragraph 4:
Your options are, therefore, to have the function take a pointer to the structure, or to take a pointer to a function of a slightly different type, such as a function taking unspecified parameters: