Describe the bug
A non GCC-Compiler (e.g. IAR Embedded Workbench) will
- find an issue with incompatible pointer type casting in TRICE_PUT16(x) in trice.h
- report unsupported #pragma GCC ...
To Reproduce
Steps to reproduce the behavior:
- Create project in IAR EW or other compiler
- Include trice v1.1.0 by adding the files from Src and creating a suitable triceConfig.h
- Hit "Build"
- See errors/warnings
Expected behavior
Project builds without warnings.
Screenshots
Original:

With proposed solution, see below:

Desktop (please complete the following information):
- OS: Windows 11
- Toolchain: IAR Embedded Workbench for Renesas RX Version 5.20.1
Solution Proposal
- Add
#ifdef __GNUC__ around the #pragma GCC, just above the macro definition of TRICE_PUT16(x) in trice.h:
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#endif // __GNUC__
- Add explicit casts from and to
TriceBufferWritePosition in the macro definition of TRICE_PUT16(x) in trice.h:
#define TRICE_PUT16(x) \
do { \
uint16_t* p_TRICE_PUT16 = (uint16_t*)TriceBufferWritePosition; \
*p_TRICE_PUT16++ = TRICE_HTOTS(x); \
TriceBufferWritePosition = (uint32_t*)p_TRICE_PUT16; \
} while (0)
Optionally, you could consider changing TriceBufferWritePosition to type (void*), because pointers can be legally casted to and from that type according to https://en.cppreference.com/w/c/language/pointer.html.
Describe the bug
A non GCC-Compiler (e.g. IAR Embedded Workbench) will
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Project builds without warnings.
Screenshots
Original:

With proposed solution, see below:

Desktop (please complete the following information):
Solution Proposal
#ifdef __GNUC__around the#pragma GCC, just above the macro definition ofTRICE_PUT16(x)in trice.h:TriceBufferWritePositionin the macro definition ofTRICE_PUT16(x)in trice.h:Optionally, you could consider changing TriceBufferWritePosition to type (void*), because pointers can be legally casted to and from that type according to https://en.cppreference.com/w/c/language/pointer.html.