Added C Binding similar to ffish.js with dllbinding_usage.md#944
Added C Binding similar to ffish.js with dllbinding_usage.md#944chocolatebakery wants to merge 1 commit intofairy-stockfish:masterfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| FSF_API int fsf_validate_fen(const char* fen, const char* variant, bool is960) { | ||
| return ffish::validate_fen(fen ? fen : "", variant ? variant : "chess", is960); | ||
| } | ||
| FSF_API const char* fsf_starting_fen(const char* variant) { | ||
| return to_cstr(ffish::starting_fen(variant ? variant : "chess")); |
There was a problem hiding this comment.
Initialize metadata calls before accessing variants
The C entry points that only query metadata (fsf_validate_fen, fsf_starting_fen, fsf_captures_to_hand) call ffish::starting_fen/validate_fen, which in turn dereference variants.find("chess")->second in get_variant without first ensuring variants.init() has run. If a client queries a starting FEN or validates a FEN before invoking fsf_init or creating a board—an expected first step when discovering available variants—the global map is still empty and this dereference is undefined and will crash. These functions should either call fsf_init (or check Board::sfInitialized) before touching variants.
Useful? React with 👍 / 👎.
C Binding similar to ffish.js, no credits to me.
Used GPT-CODEX5.1-max to create it, for self use (basically a copy-paste of ffish.js to a C binding DLL)
Cheers 🥰