osThreadGetCount() function does not exist in Mbed OS

I am trying to run the stack statistics example in Runtime memory statistics - API references and tutorials | Mbed OS 6 Documentation

However, the line
int cnt = osThreadGetCount();

induces the error “Use of undeclared identifier”. This happens for all Mbed OS from 6.5 to 6.13. What’s the problem? The heap statistics example works fine.


I tried to import and compile it for STM32F767 via Online compiler and no error occur, only few warrining.

  • What a Build tools do you use?
  • What a target do you use?

BR, Jan

I am using Mbed Studio for compiling. Target: STM32F746GZ and STM32L476RG. (P.S. Online compiler by default does not choose Mbed OS 6++)

The MbedOS version does not depend on the Online compiler but on a link what is in imported source.
How you can see here it is MbedOS 6.0.0 (see commint date from 21 may 2020 and URL address), so it is same one as in MbedStudio after import.

I tried it again with MbedStudio(1.4.1 & Arm Compiler 6 , MbedOS (6.12 & 6.14), with Nucleo-F746ZG as target and again no errors.

BR, Jan

Did you enable the correct stats in your mbed_app.json?

I did enable the correct stats in mbed_app.json. My ARM compiler is different. It’s GNU embedded arm compiler…