Computer Chess Club Archives


Search

Terms

Messages

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

Author: Dieter Buerssner

Date: 09:53:20 01/07/03

Go up one level in this thread


On January 07, 2003 at 12:26:05, Uri Blass wrote:

>>>I got that warning in the following function that is supposed to give the change
>>>in the evaluation by a move.
>>>
>>>int evalmove(move_bytes m)
>>>{
>>>	return evalmovewithoutpawns(m)+evalpawnchange(m);
>>>}
>>>
>>>evalmovewithoutpawns gives the change in the evaluation from the piece square
>>>table when evalpawnchange gives the change in the evaluation from the change in
>>>the pawn structure.

I suggest, you use a smaller warning level. The above warning is well meant, and
it may be appropriate in some cases. You may remember the related problem you
had once with

  r = rand() ^ (rand()<<15);

With this warning, you could have spotted the problem. A similar problem could
happen with your code in principle (the compiler just doesn't know).

For me MSVC with highest warning level gives hundreds of useless warning. To the
contrary, they are even warn about things, that are specifically well thought
out and coded in a portable way. One case is, a deliberate overflow in unsigned
arithmetics. Another especially anoying one is the use of multi statement macros
embedded in do {} while(0) for good reason.

Something like

#define foo() \
  do { statement1; statement2; } while(0)

It works well when used "normally" like

  foo();

and also like

  if (test)
    foo();
  else
    bar();

But it will give warnings, and when used often, zillions of warnings. The
inferior

#define foo() \
  statement1; statement2  /* May add a semicolon and some braces, it won't help
*/

Works well in the first case, and will not give any warnings. But it will yield
a syntax error when used in the second context above.

Some authors here mentioned, that they make their code warning free. I am not
going to be a slave of the compiler :-)

Actually, gcc -Wall seems to fit my likings, but not the highest warning level
of Icc or MSVC.

>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



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.