Author: Reinhard Scharnagl
Date: 08:26:00 11/24/03
Go up one level in this thread
On November 24, 2003 at 10:19:51, Zach Wegner wrote:
Hi Zach,
>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)
This seems to be a good workaround for language C, where the usage of
templates is not implemented. Also I noticed that in MS Visual Studio
the solution introduced here sometimes will not compile before the version
of C++ in .Net Studio. Then your approach might also be helpful.
But here I prefer to use a template based c++ solution.
Thank you, Reinhard.
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.