trolldbois / ctypeslib

Generate python ctypes classes from C headers. Requires LLVM clang
http://trolldbois.blogspot.com/search?q=ctypeslib
MIT License
218 stars 61 forks source link

Fails on variable of enumaterated type #95

Open wileur opened 3 years ago

wileur commented 3 years ago

It seems that clang2py parses but doesn't produce any output if the file contains a variable of an enumerated type. Running with --debug showed processing of all lines but no resulting definitions wwere printed to the terminal or output file. By commenting out line by line I finally boiled it down to the lines below.

Code:

typedef enum DETECTOR_RUN_STATES { DETECTOR_RUN_STATE_TO_IDLE, ///< Transition to Idle DETECTOR_RUN_STATE_IDLE, ///< Doing setup or in charger DETECTOR_RUN_STATE_TO_PREPARE, ///< Transition to Prepare DETECTOR_RUN_STATE_PREPARE, ///< Preparing to go active DETECTOR_RUN_STATE_TO_ACTIVE, ///< Transition to Active DETECTOR_RUN_STATE_ACTIVE ///< Active } DETECTOR_RUN_STATES_T;

// This doesn't work: //extern DETECTOR_RUN_STATES_T DETECTOR_runState;

// This works fine extern uint8_t DETECTOR_runState;

Please note that this is not a huge issue or showstopper for me, as far as I know enumerated types are mostly useful for getting nice output in a debugger that supports it. Using an uint8_t works fine, but I thought this could be useful for others.

Best regards, Andreas Wileur