@@ -34,7 +34,7 @@ generate_bindings_from_runestone :: proc(
3434 io.Error,
3535 errors.Error,
3636 } {
37- generate_includes (wd, rn) or_return
37+ generate_includes ({rs.platform}, wd, rn) or_return
3838
3939 generate_bindings_for_constants (wd, rs, rn) or_return
4040 generate_forward_declarations_for_externs (wd, rs, rn) or_return
@@ -56,7 +56,9 @@ generate_bindings_from_runecross :: proc(
5656 errors.Error,
5757 },
5858) {
59- generate_includes (wd, rn) or_return
59+ all_plats := runic.all_platforms_of_runecross (rc)
60+ generate_includes (all_plats, wd, rn) or_return
61+ delete (all_plats)
6062
6163 // Generate macros for platforms
6264 oses: [dynamic ]runic.OS
@@ -220,9 +222,32 @@ generate_bindings :: proc {
220222 generate_bindings_from_runecross,
221223}
222224
223- generate_includes :: proc (wd: io.Writer, rn: runic.To) -> io.Error {
225+ generate_includes :: proc (
226+ plats: []runic.Platform,
227+ wd: io.Writer,
228+ rn: runic.To,
229+ ) -> io.Error {
224230 io.write_string (wd, " #pragma once\n\n " ) or_return
225- io.write_string (wd, " #include <stddef.h>\n #include <stdint.h>\n\n " ) or_return
231+
232+ for plat in plats {
233+ if plat.os == .Any || plat.os == .Windows {
234+ io.write_string (
235+ wd,
236+ ` #ifdef _MSC_VER
237+ #include <BaseTsd.h>
238+ typedef SSIZE_T ssize_t;
239+ #endif
240+
241+ ` ,
242+ ) or_return
243+ break
244+ }
245+ }
246+
247+ io.write_string (
248+ wd,
249+ " #include <stddef.h>\n #include <stdint.h>\n\n " ,
250+ ) or_return
226251
227252 include_paths: [dynamic ]string
228253 defer delete (include_paths)
0 commit comments