Part Number:TMS320F28335
Tool/software: Code Composer Studio
Hi everybody,
in my application I am using this compounded structure:
typedef struct binary_i binary_i_t;
struct binary_i {
binary_t binaryClass; /*!< Binary class >*/
QFsm super[NUMBER_OF_BI]; /*!< QFsm super class >*/
bi_ctl_t biCtlQFsm[NUMBER_OF_BI]; /*!< Binary input control register >*/
};
In the code there is a function, which launches binary scanning finite state machine:
BinaryFSM_Process(QFsm *const me) {
binary_i_t *bme = ((char*)me - offsetof(binary_i_t, super[FSM_number]));
....
}
Mentioned function is invoked by this way:
BinaryFSM_Process(&BIN_scanner.biFSM[FSM_number]);
In this function I need to upcast me pointer to binary_i_t structure. Firstly, I have tried to solve it in Code::Block on my PC - with offsetof macro and (char*) upcasting, please, see this piece of code:
binary_i_t *bme = ((char*)me - offsetof(binary_i_t, super[FSM_number]));
It has been working correctly, in accordance with my wishes.
However, when I attempted to realize it in CCS6, this error was appeared: #28: expression must have a constant value. In my opinion, probably due to variable FSM_number.
At the moment I don't know, how to fix it. Is there any other method to upcast me pointer to binary_i_t structure, for exaple without offsetof macro? Why CCS6 generates error mentioned above?
Thank you a lot.