Computer Chess Club Archives


Search

Terms

Messages

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

Author: Dieter Buerssner

Date: 16:56:44 01/09/03

Go up one level in this thread


On January 08, 2003 at 18:28:56, Robert Hyatt wrote:

>On January 08, 2003 at 16:01:34, Dieter Buerssner wrote:
>
>>On January 08, 2003 at 15:45:27, Robert Hyatt wrote:
>>
>>>On January 07, 2003 at 09:16:21, Uri Blass wrote:
>>>
>>>>2)I get a lot of remarks for movei and the most popular remark is
>>>>
>>>>external definition with no prior declaration
>>>>
>>>>Do I need to declare function before I use it.
>>>
>>>Yes you must.
>>
>>Hmmm - I don't see this. Can you cite a part of the C Standard, that shows, that
>>you really "must"?
>
>Yes.
>
>The part that says "if a function is not declared before it is used, the
>assumptions are
>..."

To me it seems, you are misinterpreting it here. When a function is defined, it
is also imlicetly declared. Note, that the warning in Uri's case was not at the
place, where the function was used, but at the place, where the function was
defined.

int foo(void)
{
  return 1;
}

int main (void)
{
  return foo();
}

Is perfectly legal C. As Heiner pointed out, it can be considered bad style. If
one really need to have foo with external linkage, a prototype will be needed
somewhere. Otherwise, static int foo() would be more appropriate.

>:)
>
>By the same token, You should always use signed or unsigned when declaring chars
>since the standard leaves that an open issue as well...

I understand your point here, but I don't agree in this generality. You need
signed or unsigned, when you use char as arithmetic types, and the range 0-127
is not enough for this purpose. For a single flag (0 or 1) for example, you
don't need signed or unsigned. When using them for strings, signed or unsigned
would probably yield in many problems. All the str... functions want pointer to
char, and not pointer to signed char or pointer to unsigned char.

>>>>5)operands are evaluated in unspecified order
>>>>
>>>>It is not my fault that the intel compiler does not know that the order of
>>>>adding is not important because it does not know that calculating one expression
>>>>does not change the second expression.
>>>>
>>>>Uri
>>>
>>>The order _is_ specific.  That usually means you are mixing operators of
>>>difference
   ^^^^^^^^^^
>>>precedence without using () to specify your chosen order of evaluation.  Just
>>>add
>>>the parens to avoid some _ugly_ errors...
>>
>>The order, in which different terms are evaluated in aritmetic expressions is
>>typically _not_ specific in C. Mixing operators of _different_ precedence
>>without () is no problem at all. Normally, one would not want to write
>>
>>w = ((x*y) + z);
>
>
>Sure...  but what about the bitboard stuff that includes
>
>a>>n+1
>
>That can wreck a program silently and hideously...
>
>Depending on what you mean...

Sure, but this was not the point here. The point was, that even in

w = (x() * y()) + z());

there is no guarantee, that x() or y() are called before z(). How the function
returns values are put together, is (with or without parentheses) well defined.

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.