Skip to content

Commit 9660f71

Browse files
fix: windows wheel build
1 parent db1910b commit 9660f71

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

sciencemode/_cffi.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,9 @@ def load_library(): # noqa: C901
499499
# On Windows with MSVC, prevent stdbool.h inclusion and define bool consistently
500500
extra_compile_args.extend(
501501
[
502-
"-D_Bool=unsigned char",
503502
"-D_STDBOOL_H", # Prevent stdbool.h inclusion
504503
"-D__STDBOOL_H", # Alternative stdbool.h guard
505-
"-Dbool=unsigned char",
506-
"-Dtrue=1",
507-
"-Dfalse=0",
508-
"-D__bool_true_false_are_defined=1",
504+
# Don't define bool macros on Windows - let the compiler handle it
509505
]
510506
)
511507

@@ -848,12 +844,19 @@ def try_parse_with_better_args(header_path, header_name):
848844
"-D__declspec(x)=",
849845
]
850846

851-
bool_definitions = [
852-
"-D_Bool=unsigned char",
853-
"-Dbool=unsigned char",
854-
"-Dtrue=1",
855-
"-Dfalse=0",
856-
]
847+
# Platform-specific bool handling
848+
if platform.system() == "Windows":
849+
bool_definitions = [
850+
"-D_STDBOOL_H", # Prevent stdbool.h inclusion conflicts
851+
"-D__STDBOOL_H", # Additional header guard
852+
]
853+
else:
854+
bool_definitions = [
855+
"-D_Bool=unsigned char",
856+
"-Dbool=unsigned char",
857+
"-Dtrue=1",
858+
"-Dfalse=0",
859+
]
857860

858861
# Common definitions that work across platforms
859862
common_definitions = [
@@ -1015,18 +1018,24 @@ def try_parse_with_better_args(header_path, header_name):
10151018
unsigned char packet_input_buffer_data[120000];
10161019
unsigned char packet_input_buffer_state[100];
10171020
} Smpt_device;""",
1018-
# Basic low-level init structure
1021+
# Basic low-level init structure (matches actual Smpt_ll_init)
10191022
"""typedef struct {
1020-
unsigned char packet_number;
1021-
unsigned char electrode_count;
1022-
unsigned char reserved[14];
1023+
unsigned char measurement_type;
1024+
unsigned char high_voltage_level;
1025+
unsigned char packet_number;
10231026
} Smpt_ll_init;""",
1024-
# Channel configuration structure
1027+
# Channel configuration structure (matches actual Smpt_ll_channel_config)
10251028
"""typedef struct {
1026-
unsigned char channel_number;
1027-
unsigned char pulse_width;
1028-
unsigned char current;
1029-
unsigned char reserved[13];
1029+
unsigned char enable_stimulation;
1030+
unsigned char channel;
1031+
unsigned char connector;
1032+
unsigned char number_of_points;
1033+
struct {
1034+
unsigned short time;
1035+
float current;
1036+
unsigned char interpolation_mode;
1037+
} points[16];
1038+
unsigned char packet_number;
10301039
} Smpt_ll_channel_config;""",
10311040
# Generic acknowledgment structure (matches actual Smpt_ack)
10321041
"""typedef struct {

0 commit comments

Comments
 (0)