Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: CPP related question on double code (B/W)

Author: Zach Wegner

Date: 07:19:51 11/24/03

Go up one level in this thread


you might be able to solve this by writing a function inside a macro, and then
calling the macro twice.
e.g.

#define GENMOVESFUNC(side) \
int *genmoves##side(...) \
{ \
... \
}

GENMOVESFUNC(white)

GENMOVESFUNC(black)
...
genmoveswhite();

although this will make your code look crappy, as you need a backslash at the
end of every line.
you could also put things to avoid array lookups, like

#define GENMOVESFUNC(side, up) \
int *genmoves##side(...) \
{ \
...piece[x + up] \
}

GENMOVESFUNC(white,8)
GENMOVESFUNC(black,-8)

regards,
zach



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.