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

uint32_t nrf_log_push(char * const p_str) should be uint32_t nrf_log_push(const char * p_str)

Issue exists in SDK 15.0 and probably many many others...

I noticed that the nrf_log_push parameter is indicating it must be a constant pointer to a mutable character array.  This would actually mean the pointer must be a constant and could not be an automatic variable on the stack.  I believe the intention was a pointer to a character array that would be constant...meaning the character array could not be changed by the function. 

This stack overflow question explains the difference between (const char*)   and  (char* const).

https://stackoverflow.com/questions/890535/what-is-the-difference-between-char-const-and-const-char

As a result of this issue, I have frequently need to apply extra cast to eliminate compiler warnings.  Casting can hide real issues and should be avoided if possible.  It would be great if this issue could be addressed in the next release.

Parents Reply Children
No Data
Related