Since you use all ints (32-bit), there should be no need to use pragma pack(1). Pragma pack is evil, don't use itMichael Sherwin wrote: ↑Mon Mar 18, 2019 9:51 pm Partial success.
New sample code.Code: Select all
#pragma pack (push, 1) typedef struct { int sqr; int typ; // the type of piece, WP ... BK int clr; int prv; // the previous on board piece int nxt; // the next on board piece int val; // the value of the piece } ps; // piece-structure typedef struct { int castle; int epsq; } ss; // search-structure typedef struct { int wtm; // white-to-move int ply; // search ply int castle; // castling status int epsq; // capture e.p. square if any int fifty; int board[64]; ps p[40]; // index piece array ss s[100]; // search stack } ts; #pragma pack (pop) ts *t = new ts; extern "C" int MoveGen(ts *); int main() { int code; code = MoveGen(t); code = t->p[0].nxt; }
You can always reorder the structs so that you don't need anything fancy.
Anyway I'm glad it works for you now.
One last thing: don't use pragma pack, really Ever.
It should be removed from all compilers and its spec buried 10km underground