This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Compilation Error

SDK 15.3

Hi,

I keep getting the following error when compiling. What file am I missing or what setting do I need to set in sdk_config? I am getting this error when compiling in nrf_queue.c

\nrf_queue.c", Error: #136: struct "<unnamed>" has no field "p_log"
NRF_LOG_INST_WARNING(p_queue->p_log, "Queue full. Overwriting oldest element.");..

Also, this:

\nrf_queue.c", Error: #136: struct "<unnamed>" has no field "p_log"
NRF_LOG_INST_DEBUG(p_queue->p_log, "pushed element 0x%08X, status:%d", p_element, status);

I am assuming I am missing a header file or did not set something correctly in the sdk_config.h. 

Thanks for your help!

  • Hi,

    Looking at the definition of nrf_queue_t it seems that the use of NRF_LOG_INSTANCE_PTR_DECLARE()  will make it so that the p_log field only exists if logging (NRF_LOG_ENABLED) and log filters (NRF_LOG_FILTERS_ENABLED) are enabled in sdk_config.h.

  • What if I do not want logging at all in my code as it brings in unnecessary files that I do not use? Can I not turn it off (NRF_LOG_ENABLED to 0 in sdk_config.h) and compile nrf_queue library? 

  • Hi,

    That should not be a problem. If logging is disabled (NRF_LOG_ENABLED set to 0 in sdk_config.h, then NRF_LOG_INST_WARNING and NRF_LOG_INST_DEBUG are removed by the preprocessor (expanded to nothing). You can experiment with this out of the box using, for instance, the RNG example, since the RNG driver uses nrf_queue.

    I do not see how this can fail, so it would be interesting to know what you have done in your project. What is the full output from the build, including warnings etc? Can you upload your project here so I can test on my side?

  • Thanks Einar. I think the issue was that I was using an older version of nrf_log.h file which did not contain the NRF_LOG_INST_WARNING define. Once I use the new one, I think I am good to go. I haven't tested this yet.

    But still my concern is, if I just want to use nrf_queue library, I still need to include nrf_log.h (even if logging is turned off, it is an include dependency [line 53 nrf_queue.c]). If you bring in nrf_log.h, you need to bring in nrf_log_internal.h which brings in more headers and so on. My concern if I just want to use nrf_queue and no logging, I shouldn't have to bring in nrf_log and all other headers associated with that. Just a SDK design thing for the future.

  • Hi,

    superpak said:
    My concern if I just want to use nrf_queue and no logging, I shouldn't have to bring in nrf_log and all other headers associated with that. Just a SDK design thing for the future.

    Thank you for the feedback. I see your point and agree that it can be annoying with all the additional includes, which includes more files etc. However, logging, in particular, is something most developers want so that they can easily turn it on to ease debugging when there is an issue. And then they can easily turn it off again when not needed. The current approach makes it easy to control it via sdk_config.h, and the preprocessor will remove everything if it is turned off. So even if you get a large number of files in your project, it very easy to remove everything from your binary when you don't need or want it.

Related