NordicSemiconductor / zcbor

Low footprint C/C++ CBOR library and Python tool providing code generation from CDDL descriptions.
Apache License 2.0
105 stars 34 forks source link

Implicit declaration of function ‘strnlen’ in zcbor_encode.c & zcbor_decode.c #390

Closed aescolar closed 5 months ago

aescolar commented 5 months ago

Both zcbor_encode.c & zcbor_decode.c use strnlen()

In general these 2 functions are only exposed by the C library if _POSIX_C_SOURCE is set 200809L But neither of these files (or their build scripts), are setting this macro, causing build warnings (Implicit declaration of function ‘strnlen’) which turn into failures in CI with some libCs.

Setting these macros like for example here: https://github.com/aescolar/zephyr/commit/39537c345ef8c3bb3d21974af0f3f1d83857233c#diff-76744cde2b405317ce908f4f05396673f0728ee80bc90d08e14c346409668d67R10-R11 Is safe and solves this issue.

For failures see for example: https://github.com/zephyrproject-rtos/zephyr/actions/runs/7656771227/job/20865881130?pr=67052#step:12:1648

aescolar commented 5 months ago

CC @oyvindronningstad

aescolar commented 5 months ago

Related https://github.com/NordicSemiconductor/zcbor/pull/385

oyvindronningstad commented 5 months ago

@aescolar Thanks, I will publish a 0.8.1 and update Zephyr.