Chess game data structure in C

Discussion of chess software programming and technical issues.

Moderator: Ras

Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Chess game data structure in C

Post by Sven »

mathmoi wrote:Even if I did write it in C++ and offer a C interface to access it from C programs I would still have to deal with the "simulated inheritance" to pass the game back to C programs.
That depends on what you offer as part of such an interface, which in turn depends on what a user of your library shall be able to do. It might be possible to provide the whole access to a game via C functions without any knowledge about the internal game data structure.

Sven
lucasart
Posts: 3242
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Chess game data structure in C

Post by lucasart »

Sven Schüle wrote:
mathmoi wrote:Even if I did write it in C++ and offer a C interface to access it from C programs I would still have to deal with the "simulated inheritance" to pass the game back to C programs.
That depends on what you offer as part of such an interface, which in turn depends on what a user of your library shall be able to do. It might be possible to provide the whole access to a game via C functions without any knowledge about the internal game data structure.

Sven
I would suggest the opposite: write a C library and C++ wrappers for it. There is even a tool for automating it
http://developer.gnome.org/gtkmm-tutori ... es.html.en
However, it seems tightly bound to GTK stuff. I don't know if this tool can be used in a more general way, without any links to GTK.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
mathmoi
Posts: 290
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec
Full name: Mathieu Pagé

Re: Chess game data structure in C

Post by mathmoi »

lucasart wrote:
Sven Schüle wrote:
mathmoi wrote:Even if I did write it in C++ and offer a C interface to access it from C programs I would still have to deal with the "simulated inheritance" to pass the game back to C programs.
That depends on what you offer as part of such an interface, which in turn depends on what a user of your library shall be able to do. It might be possible to provide the whole access to a game via C functions without any knowledge about the internal game data structure.

Sven
I would suggest the opposite: write a C library and C++ wrappers for it. There is even a tool for automating it
http://developer.gnome.org/gtkmm-tutori ... es.html.en
However, it seems tightly bound to GTK stuff. I don't know if this tool can be used in a more general way, without any links to GTK.
My plan was to write the parser in C and let C++ programmers use it as is. C being a subset of C++ (I know it's not really), it is easier for C++ programmers to use C code than the opposite. This being said, I might provide a C++ wrapper in the future to make the interface more natural in a C++ program.