OpenCyphal / libcanard

A compact implementation of the Cyphal/CAN protocol in C for high-integrity real-time embedded systems
http://opencyphal.org
MIT License
332 stars 192 forks source link

NuttX UINT32_C portability issue #145

Closed PetervdPerk-NXP closed 4 years ago

PetervdPerk-NXP commented 4 years ago

When compiling libcanardv1 for NuttX I get multiple undefined reference errors regarding the UINT32_C macro

libcanard/canard.c:186: undefined reference to `UINT32_C'

Looking at the stdint.h header from NuttX it seems that they don't define this macro

#if 0 /* REVISIT: Depends on architecture specific implementation */
#define INT8_C(x)           x
#define INT16_C(x)          x
#define INT32_C(x)          x ## l
#define INT64_C(x)          x ## ll

#define UINT8_C(x)          x
#define UINT16_C(x)         x
#define UINT32_C(x)         x ## ul
#define UINT64_C(x)         x ## ull
#endif

Not sure if this issue is NuttX specific, thus this issue should be resolved inside NuttX. Or we could add some kind of compatibility check e.g. ifndef in canard?

pavel-kirienko commented 4 years ago

Per section 7.20.4.1 of the ISO C11 standard, these macros shall be defined by a compliant implementation of the standard library. Please report this bug to the NuttX maintainers.

Meanwhile, as a workaround, you can provide -DUINT32_C(x)=x##ull to the compiler.