Following jldupont's answer on defining variables with varying data, I defined the following:
enum buffer_format
{
FIFO_U8T = 0,
FIFO_U16T
};
struct buffer_param
{
enum buffer_format type;
union
{
struct buffer_fifo_u8_t *fifo_u8;
struct buffer_fifo_u16_t *fifo_u16;
} is;
};
I then coded the following assignments:
struct buffer_param fifo_uartTx_param;
fifo_uartTx_param.is.fifo_u8 = &fifo_uartTx;
fifo_uartTx_param.type = FIFO_U8T;
However, I am met with some errors that complain that I can't simply reach into my buffer_param type struct to make these assignments. How would I assign the pointer to the UART fifo and set its type?
error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
fifo_uartTx_param.is.fifo_u8 = &fifo_uartTx;
^
error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
fifo_uartTx_param.type = FIFO_U8T;
^