Converting C/C++ Code to D (#define extern)

Lutger lutger.blijdestijn at gmail.com
Tue Sep 26 11:06:00 PDT 2006


Nice, I'm sure the D code will be a lot cleaner. Have you found relevant 
links on digital mars? These I found useful:

http://www.digitalmars.com/d/htomodule.html
http://www.digitalmars.com/d/ctod.html
http://www.digitalmars.com/d/cpptod.html
http://www.digitalmars.com/d/pretod.html

If you're willing to share I would be interested in the end result.

exiquio wrote:
> Good day to all.
> 
> I am writing an chess engine based upon an established C++ engine as a 
> interesting, yet practical excersise.
> 
> While translating a header file (I am not proficiant in C\C++) I ran into 
> some things I find difficult findinf a way to do in D. Here are a few 
> examples of what I am talking about (w/ no particular order):
> 
> CODE:
> 
> #define PawnListStart(pos,side) PieceListStart(pos,PawnOfColour(side))
> #define KnightListStart(pos,side) PieceListStart(pos,KnightOfColour(side))
> #define BishopListStart(pos,side) PieceListStart(pos,BishopOfColour(side))
> #define RookListStart(pos,side) PieceListStart(pos,RookOfColour(side))
> #define QueenListStart(pos,side) PieceListStart(pos,QueenOfColour(side))
> 
> 
> #define MovePiece(pos,from,to) do {                 \
>     PieceList(pos,to) = PieceList(pos,from);            \
>     PrevPiece(pos,NextPiece(pos,to)) = to;      \
>     NextPiece(pos,PrevPiece(pos,to)) = to;      \
>   } while(0)
> 
> 
> extern uint8 PawnRank[2][128];
> extern attack_data_t AttackData_[256];
> extern attack_data_t *AttackData;
> 
> END CODE
> 
> Forgive me for being ignorant and thanks in advance.



More information about the Digitalmars-d-learn mailing list