Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: about using killers in Rebel and about programming

Author: Uri Blass

Date: 05:33:19 01/01/03

Go up one level in this thread


On January 01, 2003 at 07:04:29, Dave Gomboc wrote:

>>>>This was only thinking about a theoretical case but I found other things in my
>>>>code.
>>>>
>>>>In a lot of places in my program
>>>>I have a condition like
>>>>
>>>>while (target!=-1&&info[target]==EMPTY)
>>>>
>>>>In most cases target!=-1
>>>>
>>>>I thought that I need to do the && in this order
>>>>Do you say that I can change the order without risks?
>>>>
>>>>Suppose that the loop stops in most of the cases because of the fact that
>>>>info[target]=EMPTY.
>>>>
>>>>Does it going to do my program faster or maybe the compiler can detect these
>>>>cases in profile optimazions?
>>>>
>>>>I thought that even checking the value of info[-1] can give an error or change
>>>>some varaible that I do not want.
>>>>
>>>>Uri
>>>
>>>Technically, checking the value of info[-1] could even cause your program to
>>>crash.  But in practice, as long as your program has the ability to access the
>>>memory immediately in front of info, it will probably just read the value in
>>>that memory location.
>>>
>>>To be slightly safer, you can declare a padded_info like I suggested elsewhere
>>>in this thread.  That way even assignments to info[-1] won't cause a problem --
>>>on most architectures, with most compilers.
>>>
>>>>while (target!=-1&&info[target]==EMPTY)
>>>
>>>Technically it would be wrong to flip this test around, but in practice you can
>>>probably get away with it.
>>>
>>>Dave
>>
>>originally info is a global array and
>>I have int info[64];
>>
>>If I understand correctly
>>Based on your example I can use in data.c
>>
>>int PADDED_info[65];
>>int * const info = PADDED_info+1;
>
>Yes.

Does not work for me


I deleted from data.c
int info[64];
I deleted from data.h
extern info[64];

I added to data.h
extern int PADDED_info[65];
extern int * const info = PADDED_info+1;

I added to data.c

int PADDED_info[65];
int * const info = PADDED_info+1;


This is what I got as a result(I still do not use the intel compiler).

data.obj : error LNK2005: _info already defined in boardi.obj
evaluate.obj : error LNK2005: _info already defined in boardi.obj
main.obj : error LNK2005: _info already defined in boardi.obj
Release/main.exe : fatal error LNK1169: one or more multiply defined symbols
found
Error executing xilink6.exe.

main.exe - 4 error(s), 0 warning(s)

Uri



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.