This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: trying to understand: "warning: function declaration isn't a prototype"
Am Donnerstag, 6. Juli 2006 11:21 schrieb Jay Vaughan:
> >Well, I explained why the warning is being emitted.
>
> Yes, because I haven't suppressed it with a switch .. but what I want
> to know is what the warning means.
>
> >Perhaps you could rephrase your question. Or perhaps you could
> >provide the exact error message and the line in the source code to
> >which it refers.
>
> ../../common/Headers/msExtern.h:60: warning: function declaration
> isn't a prototype
>
> ------------------------------------
> msTypes.h (#included by msDefs.h):
> #define FAR
> #define FarPtr(type) type FAR *
>
>
> ------------------------------------
> msDefs.h (#included by msExtern.h)
>
> typedef FarPtr(void) TApplContextPtr;
>
>
> ------------------------------------
> msExtern.h:60:
>
> TApplContextPtr CreateApplContext ();
>
>
> ------------------------------------
> msLinux.c:
>
> TApplContextPtr CreateApplContext()
> {
> LinuxContextPtr ptr =
> (LinuxContextPtr) kmalloc(sizeof(LinuxContext), GFP_KERNEL);
> //.. etc ..
> return ptr;
> }
>
>
>
> The way I interpret this warning, its telling me that "FarPtr(void)
> CreatApplContext();" resolves to " * CreateApplContext();" .. clearly
> not a friendly prototype .. but which I suppose should probably be
> something more like (void) *CreateApplContext(); .. meaning I should
> fix the "#define FAR" to be "#define FAR void" instead ..
You might look at the results of the prototyping you can choose gcc -E
some_file.c and see the result:
I attached xy.c. The result of
gcc -E xy.c | grep "typedef.*AbcPtr" is
typedef void * AbcPtr;
which seems to be ok.
You should lookup if the definitions above are somehow hidden by conditionals,
which you also can control via gcc -E.
#include <stdio.h>
#define FAR
#define FarType(x) x FAR *
typedef FarType(void) AbcPtr;
extern AbcPtr func();
AbcPtr func()
{
printf( "hello far ptr\n" );
return (AbcPtr)NULL;
}
int main(int argc, char** argv)
{
func();
return 0;
}