187187 "-D__declspec(x)=" ,
188188 "-D__forceinline=" ,
189189 "-D__inline=" ,
190- # On Windows, avoid redefining bool to prevent conflicts with MSVC stdbool.h
190+ # On Windows, prevent stdbool.h inclusion and define bool consistently
191191 "-D_Bool=unsigned char" ,
192- # Don't redefine bool/true/false - let MSVC handle it
192+ "-D_STDBOOL_H" , # Prevent stdbool.h inclusion
193+ "-D__STDBOOL_H" , # Alternative stdbool.h guard
194+ "-Dbool=unsigned char" ,
195+ "-Dtrue=1" ,
196+ "-Dfalse=0" ,
193197 ]
194198 if sys .platform .startswith ("win" )
195199 else [
@@ -492,12 +496,16 @@ def load_library(): # noqa: C901
492496 ]
493497 )
494498else :
495- # On Windows with MSVC, let the compiler handle bool definitions
496- # Only define _Bool for consistency in parsing
499+ # On Windows with MSVC, prevent stdbool.h inclusion and define bool consistently
497500 extra_compile_args .extend (
498501 [
499502 "-D_Bool=unsigned char" ,
500- # Don't redefine bool/true/false on Windows to avoid conflicts
503+ "-D_STDBOOL_H" , # Prevent stdbool.h inclusion
504+ "-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" ,
501509 ]
502510 )
503511
@@ -645,11 +653,24 @@ def preprocess_header_manually(header_path):
645653 # Don't redefine __STDC_VERSION__ - that causes the macOS redefinition warning
646654 if platform .system () == "Windows" :
647655 asm_definition = "#define __asm__"
648- # On Windows, be more careful with bool to avoid MSVC conflicts
656+ # On Windows, prevent stdbool.h inclusion and define bool consistently
649657 bool_definitions = """
658+ /* Prevent stdbool.h inclusion */
659+ #ifndef _STDBOOL_H
660+ #define _STDBOOL_H 1
661+ #endif
662+ #ifndef __STDBOOL_H
663+ #define __STDBOOL_H 1
664+ #endif
665+
650666#ifndef _Bool
651667typedef unsigned char _Bool;
652668#endif
669+ #ifndef bool
670+ #define bool unsigned char
671+ #define true 1
672+ #define false 0
673+ #endif
653674"""
654675 else :
655676 asm_definition = "#define __asm__(...)"
@@ -707,10 +728,14 @@ def try_parse_with_better_args(header_path, header_name):
707728 # Platform-specific __asm__ definition and bool handling
708729 if platform .system () == "Windows" :
709730 asm_definition = "-D__asm__="
710- # On Windows, be more careful with bool definitions to avoid MSVC conflicts
731+ # On Windows, prevent stdbool.h inclusion and define bool consistently
711732 bool_definitions = [
712733 "-D_Bool=unsigned char" ,
713- # Don't redefine bool on Windows to avoid MSVC stdbool.h conflicts
734+ "-D_STDBOOL_H" , # Prevent stdbool.h inclusion
735+ "-D__STDBOOL_H" , # Alternative stdbool.h guard
736+ "-Dbool=unsigned char" ,
737+ "-Dtrue=1" ,
738+ "-Dfalse=0" ,
714739 ]
715740 else :
716741 asm_definition = "-D__asm__(...)="
@@ -841,12 +866,13 @@ def try_parse_with_better_args(header_path, header_name):
841866 [
842867 # Basic device structure with essential fields (matches actual Smpt_device)
843868 """typedef struct {
844- int file_descriptor;
845- char device_name[256];
846- unsigned char packet_number;
847- unsigned char is_connection_established;
848- unsigned char is_version_ack_received;
849- unsigned char last_packet_number_received;
869+ unsigned int packet_length;
870+ unsigned char packet[1200];
871+ unsigned char cmd_list_data[1000];
872+ signed char current_packet_number;
873+ char serial_port_name[256];
874+ unsigned char packet_input_buffer_data[120000];
875+ unsigned char packet_input_buffer_state[100];
850876 } Smpt_device;""" ,
851877 # Basic low-level init structure
852878 """typedef struct {
@@ -873,9 +899,8 @@ def try_parse_with_better_args(header_path, header_name):
873899 # Generic acknowledgment structure (matches actual Smpt_ack)
874900 """typedef struct {
875901 unsigned char packet_number;
876- unsigned char command_number;
902+ unsigned short command_number;
877903 unsigned char result;
878- unsigned char reserved[13];
879904 } Smpt_ack;""" ,
880905 ]
881906 )
0 commit comments