Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: How to get rid of remarks of the intel compiler

Author: Heiner Marxen

Date: 13:41:28 01/07/03

Go up one level in this thread


On January 07, 2003 at 12:53:20, Dieter Buerssner wrote:

>On January 07, 2003 at 12:26:05, Uri Blass wrote:
>
[...]
>>I do not know if I need to do it when there is no decleration
>>I get also warning for functions that get parameters when they are not declared,
>>
>>external definition with no prior declaration
>>  void addp(int square)
>
>static void addp(int square)
>
>>
>>It seems that the only way to avoid the warning is to add decleration for every
>>function that I have and changing int foo() to int foo(void) is not going to
>>make it.
>
>You can ignore it. One advice however will be, to declare those functions
>static. When you only use it after you defined it (in this case certainly a
>prototype is not needed), static will be the appropriate type. It may even speed
>up your code, because it may allow the compiler to do more aggressive
>optimizations. Probably even the warnings will go away.
>
>Regards,
>Dieter

Yes, that is exactly what I expect to be the correct solution.

Reasoning for the warning...

If a function is not "static", it is de facto exported, i.e. other source
files may call this function.  But since here, at the function definition,
the compiler did not yet see any prototype declaration, most probably
there is no prototype for the real caller (in the other source), either.
And that could result in serious errors.

While it is legal to do so, it is bad style, at least.
Every function should either be static (hidden), or should have a prototype
declaration in the export interface (the corresponding header file).

Gcc has a warning option -Wmissing-declarations to produce exactly this
kind of diagnostic.  I find it very useful.

Cheers,
Heiner



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.