Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

M_SQRT1_2 and other macros undefined after math.h included

I'm developing against the nRF5340 DK for the time being as I wait for hardware. 

Latest nRF SDK using Zephyr.  

This is a porting project and makes use of DSP and float math.  

One particular function uses M_SQRT1_2 macro but when I compile I get an undefined error. 

CONFIG_FPU=y

CONFIG_NEWLIB_LIBC=y 

If I right click and go to the definition it is found.  Scratching my head on this one as it's not the first time I've used NEWLIBC and Zephyr with floating point math. 

Any suggestions would be appreciated. 

Parents
  • Hi Mike

    I got a case earlier where someone was looking for the M_PI macro in math.h, but couldn't find it in our libraries. 

    Back then I provided a link to a stack overflow thread, here,  which explains the situation. 

    Essentially these macros are not a part of the math API standard, and as such they are not guaranteed to be available in all implementations. 

    Looking at the math.h file it is indeed implemented on some platforms, but not on all, which is why the build fails. 

    I can check with the team if this could be made available regardless of the platform, but since this module is not provided by Nordic it is not something we have direct control over. In the short term I would recommend simply copying the definitions you need into a separate header file that you can include in your application. 

    Best regards
    Torbjørn

  • Interesting.  Fair enough I can do that.  It's just odd that when I go to the header my system thinks is included its there but compile fails. 

    I'll stash the definitions in my own header to pull it in.  Thank you. 

    Mike 

Reply Children
Related