Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

EVT_TO_STR() usage in nrf_drv_rtc.c incorrect?

Hi!

Compiler errors are popping up when working on nrf_drv_rtc.c while log is enabled for this nRF module.

I see that the problem is any log statement that contains EVT_TO_STR().
First, the print format specifier has "%s", but the result of this macro is being casted to uint32_t.

An example from row 309 in nrf_drv_rtc.c:

            NRF_LOG_DEBUG("Event: %s, instance id: %d.",
                         (uint32_t)EVT_TO_STR(event), (uint32_t)instance_id);

When removing the cast, still the following persists:

Therefore I have no medicine for this macro ternary soup.
SDK version is 14.1 but I see that in version 14.2 this has not changed.

Cheers!

Parents
  • Hi,

    Thanks for reporting. I found an internal bug report for this, but it doesn't seem to have been fixed yet. However, you can try to fix it yourself by adding 5 ')'-characters at the end of the EVT_TO_STR() macro like this:

    #define EVT_TO_STR(event)   (event == NRF_RTC_EVENT_TICK ? "NRF_RTC_EVENT_TICK" :               \
                                (event == NRF_RTC_EVENT_OVERFLOW ? "NRF_RTC_EVENT_OVERFLOW" :       \
                                (event == NRF_RTC_EVENT_COMPARE_0 ? "NRF_RTC_EVENT_COMPARE_0" :     \
                                (event == NRF_RTC_EVENT_COMPARE_1 ? "NRF_RTC_EVENT_COMPARE_1" :     \
                                (event == NRF_RTC_EVENT_COMPARE_2 ? "NRF_RTC_EVENT_COMPARE_2" :     \
                                (event == NRF_RTC_EVENT_COMPARE_3 ? "NRF_RTC_EVENT_COMPARE_3" : "UNKNOWN EVENT"))))))

     

Reply
  • Hi,

    Thanks for reporting. I found an internal bug report for this, but it doesn't seem to have been fixed yet. However, you can try to fix it yourself by adding 5 ')'-characters at the end of the EVT_TO_STR() macro like this:

    #define EVT_TO_STR(event)   (event == NRF_RTC_EVENT_TICK ? "NRF_RTC_EVENT_TICK" :               \
                                (event == NRF_RTC_EVENT_OVERFLOW ? "NRF_RTC_EVENT_OVERFLOW" :       \
                                (event == NRF_RTC_EVENT_COMPARE_0 ? "NRF_RTC_EVENT_COMPARE_0" :     \
                                (event == NRF_RTC_EVENT_COMPARE_1 ? "NRF_RTC_EVENT_COMPARE_1" :     \
                                (event == NRF_RTC_EVENT_COMPARE_2 ? "NRF_RTC_EVENT_COMPARE_2" :     \
                                (event == NRF_RTC_EVENT_COMPARE_3 ? "NRF_RTC_EVENT_COMPARE_3" : "UNKNOWN EVENT"))))))

     

Children
No Data
Related