public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* trying to understand: "warning: function declaration isn't a  prototype"
@ 2006-07-05 14:43 Jay Vaughan
  2006-07-05 16:39 ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Jay Vaughan @ 2006-07-05 14:43 UTC (permalink / raw)
  To: gcc-help

gcc: gcc version 2.95.3 20010315 (release)

i get these warnings on a project i'm trying to port using 
arm-linux-gcc .. is there some place i can find a more detailed 
description of what these warnings mean and how i can clean them up? 
i am having problems with my project and suspect that it is related 
to these prototypes being mis-handled as the function declaration, 
instead of just being handled as a prototype ..

-- 

;

Jay Vaughan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: trying to understand: "warning: function declaration isn't a  prototype"
  2006-07-05 14:43 trying to understand: "warning: function declaration isn't a prototype" Jay Vaughan
@ 2006-07-05 16:39 ` Ian Lance Taylor
  2006-07-05 17:23   ` Jay Vaughan
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2006-07-05 16:39 UTC (permalink / raw)
  To: Jay Vaughan; +Cc: gcc-help

Jay Vaughan <jv@access-music.de> writes:

> gcc: gcc version 2.95.3 20010315 (release)
> 
> i get these warnings on a project i'm trying to port using
> arm-linux-gcc .. is there some place i can find a more detailed
> description of what these warnings mean and how i can clean them up? i
> am having problems with my project and suspect that it is related to
> these prototypes being mis-handled as the function declaration,
> instead of just being handled as a prototype ..

The warning means that the code does something like this:
    extern int foo ();

The warning message will include a file name and line number you can
use to see where this is happening.

You can turn off the warning with -Wno-strict-prototypes (or simply by
omitting -Wstrict-prototypes).

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: trying to understand: "warning: function declaration isn't a   prototype"
  2006-07-05 16:39 ` Ian Lance Taylor
@ 2006-07-05 17:23   ` Jay Vaughan
  2006-07-05 17:27     ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Jay Vaughan @ 2006-07-05 17:23 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

>The warning means that the code does something like this:
>     extern int foo ();
>The warning message will include a file name and line number you can
>use to see where this is happening.
>

yes, i understand this - i do not want to ignore this warning, i want 
to understand why the warning is emitted in the first place ..


-- 

;

Jay Vaughan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: trying to understand: "warning: function declaration isn't a  prototype"
  2006-07-05 17:23   ` Jay Vaughan
@ 2006-07-05 17:27     ` Ian Lance Taylor
  2006-07-06  9:21       ` Jay Vaughan
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2006-07-05 17:27 UTC (permalink / raw)
  To: Jay Vaughan; +Cc: gcc-help

Jay Vaughan <jv@access-music.de> writes:

> >The warning means that the code does something like this:
> >     extern int foo ();
> >The warning message will include a file name and line number you can
> >use to see where this is happening.
> >
> 
> yes, i understand this - i do not want to ignore this warning, i want
> to understand why the warning is emitted in the first place ..

Well, I explained why the warning is being emitted.

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.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: trying to understand: "warning: function declaration isn't a   prototype"
  2006-07-05 17:27     ` Ian Lance Taylor
@ 2006-07-06  9:21       ` Jay Vaughan
  2006-07-06 11:32         ` Ingo Krabbe
  2006-07-06 13:30         ` Ian Lance Taylor
  0 siblings, 2 replies; 10+ messages in thread
From: Jay Vaughan @ 2006-07-06  9:21 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

>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 ..

-- 

;

Jay Vaughan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: trying to understand: "warning: function declaration isn't a   prototype"
  2006-07-06  9:21       ` Jay Vaughan
@ 2006-07-06 11:32         ` Ingo Krabbe
  2006-07-06 11:44           ` Ingo Krabbe
  2006-07-06 13:30         ` Ian Lance Taylor
  1 sibling, 1 reply; 10+ messages in thread
From: Ingo Krabbe @ 2006-07-06 11:32 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1783 bytes --]

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.

[-- Attachment #2: xy.c --]
[-- Type: text/x-csrc, Size: 240 bytes --]

#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;
}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: trying to understand: "warning: function declaration isn't a   prototype"
  2006-07-06 11:32         ` Ingo Krabbe
@ 2006-07-06 11:44           ` Ingo Krabbe
  0 siblings, 0 replies; 10+ messages in thread
From: Ingo Krabbe @ 2006-07-06 11:44 UTC (permalink / raw)
  To: gcc-help

Am Donnerstag, 6. Juli 2006 13:32 schrieb Ingo Krabbe:
>
> 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.

Ah and I even could reproduce your warning message, but it wasn't that easy 
since gcc -Wall -Wextra -pedantic -ansi xy.c gives no warning.  So I had to 
turn on -Wstrict-prototypes.  The warning vanishes when you write:

TApplContextPtr CreateApplContext (void);
                                   ^^^^   the void here makes the difference


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: trying to understand: "warning: function declaration isn't a  prototype"
  2006-07-06  9:21       ` Jay Vaughan
  2006-07-06 11:32         ` Ingo Krabbe
@ 2006-07-06 13:30         ` Ian Lance Taylor
  1 sibling, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2006-07-06 13:30 UTC (permalink / raw)
  To: Jay Vaughan; +Cc: gcc-help

Jay Vaughan <jv@access-music.de> writes:

> >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.

There is a friendly manual which describes all the options.  Please
read it.

> TApplContextPtr CreateApplContext ();

-Wstrict-prototypes will issue a warning for this function declaration
because it is not a prototype.  An equivalent declaration with a
prototype would be:
  TApplContextPtr CreateApplContext (void);

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: trying to understand: "warning: function declaration isn't a    prototype"
  2006-07-06 13:28 John Yates
@ 2006-07-06 13:31 ` Jay Vaughan
  0 siblings, 0 replies; 10+ messages in thread
From: Jay Vaughan @ 2006-07-06 13:31 UTC (permalink / raw)
  To: John Yates, Ian Lance Taylor; +Cc: gcc-help

>I believe the issue is that empty parentheses do not constitute a valid
>prototype and that to be truly conformant you would have to write:
>     extern int foo (void);

oh man that is so obvious it hurts to be discussing it .. thanks for 
pointing that out!  :)

-- 

;

Jay Vaughan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: trying to understand: "warning: function declaration isn't a   prototype"
@ 2006-07-06 13:28 John Yates
  2006-07-06 13:31 ` Jay Vaughan
  0 siblings, 1 reply; 10+ messages in thread
From: John Yates @ 2006-07-06 13:28 UTC (permalink / raw)
  To: Jay Vaughan, Ian Lance Taylor; +Cc: gcc-help

Ian Lance Taylor wrote:
>
> The warning means that the code does something like this:
>      extern int foo ();

To which Jay Vaughan replied:
>
> yes, i understand this - i do not want to ignore this warning, i want 
> to understand why the warning is emitted in the first place ..


I believe the issue is that empty parentheses do not constitute a valid
prototype and that to be truly conformant you would have to write:

    extern int foo (void);

/john

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-07-06 13:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-05 14:43 trying to understand: "warning: function declaration isn't a prototype" Jay Vaughan
2006-07-05 16:39 ` Ian Lance Taylor
2006-07-05 17:23   ` Jay Vaughan
2006-07-05 17:27     ` Ian Lance Taylor
2006-07-06  9:21       ` Jay Vaughan
2006-07-06 11:32         ` Ingo Krabbe
2006-07-06 11:44           ` Ingo Krabbe
2006-07-06 13:30         ` Ian Lance Taylor
2006-07-06 13:28 John Yates
2006-07-06 13:31 ` Jay Vaughan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).