Arm Mbed OS support forum

How to stop Mbed Studio from adding unwanted libraries?

I’m using Mbed Studio with a Mbed OS6 project. I’m developing a module written in C, using stdint.h and other standard libraries. There are no direct dependencies on mbed.h, I’m trying to keep my module standalone so it can be used with other frameworks. From time to time the cstdint is added at the beginning of my files. Producing the following errors:

Too many errors emitted, stopping now clang(fatal_too_many_errors)
In included file: unknown type name '_LIBCPP_BEGIN_NAMESPACE_STD' clang(unknown_typename

It happens to any file .c, .h or .cpp but the error is only shown on the .c files. It doesn’t seem to be systematic error, sometimes I’m able to write my code for hours without issues and sometimes it happens every 5 minutes.

I have the content of my header file wrapped with:

#ifdef __cplusplus
extern "C" {
#endif
       //  Code
#ifdef __cplusplus
}
#endif

Maybe I’m doing something wrong mixing C and CPP and I don’t know if it is Mbed Studio or Clang, but it is the first time I see an editor adding things to my code on its own.

Removing the added library fixes the issue and the code runs well. Any idea on how to disable the auto-inclusion of libraries? Thank you.

PS: I don’t know how to tell what Mbed Studio version I’m using but I updated it a few days ago, however this issue happened to me before as well. If the version is needed please provide some guidance on how to find it.

Hi Daniel,

Thank you for reporting this issue. We can reproduce this issue and will work on a fix. It seems that in some particular cases Clangd 11.0.0 used in Studio finds standard library cstdint instead of a header from Mbed OS library.

Thanks,
Arek - Studio team

Hello, thanks for replying! I’ll be following the updates.