I am using this nice tool, clang2py, to convert macros, enums and structs in C headers to ctypes.Structure in Python. One thing I notice is that macro values with parenthesis are not converted by clang2py. Here is a quick example:
I converted this C header file by executing clang2py -k m /path/to/header.h, but the generated Python code only defined MACRO_NAME1 as a variable as shown below:
In general, having parenthesis around the macro values is a good practice in C/C++. The header files that I have follow that convention, so none of the macro values weren't converted to Python variables, unfortunately.
Could you probably fix clang2py in some way so that those macro values can be converted properly?
FYI, below is the dump of clang2py --version in my environment:
Hi,
I am using this nice tool,
clang2py
, to convert macros, enums and structs in C headers to ctypes.Structure in Python. One thing I notice is that macro values with parenthesis are not converted byclang2py
. Here is a quick example:I converted this C header file by executing
clang2py -k m /path/to/header.h
, but the generated Python code only definedMACRO_NAME1
as a variable as shown below:In general, having parenthesis around the macro values is a good practice in C/C++. The header files that I have follow that convention, so none of the macro values weren't converted to Python variables, unfortunately.
Could you probably fix
clang2py
in some way so that those macro values can be converted properly?FYI, below is the dump of
clang2py --version
in my environment: