I like to get rid of a compiler warning which only appears with the optimization switch -O2 or -O3.
This is the warning:
protocol.c:111: warning: dereferencing type-punned pointer will break strict-aliasing rules
This is the prototype of a function which call causes the warning:
extern unsigned char get_cobs_tx_buf(unsigned char **tx_buf);
For this function call I get the above mentioned warning:
t2m_error_t *msg; unsigned char idx; idx=get_cobs_tx_buf((unsigned char **)(&msg));
But the following function call does not cause a warning:
unsigned char *msg; unsigned char idx; idx=get_cobs_tx_buf(&msg);
1. Am I doing anything wrong? (Although the code seems to work...)
2. Is it possible to change the optimization level by a #pragma?
3. Can I supress a certain warning or a group of warnings by a #pragma?
Thanks in advance!