Sudden error - cstddef: No such file or directory|

I have no idea where this error came from, everything was working fine, I hibernated my computer, came back later, clicked to compile my code and then -

.\PokittoLib\mbed-pokitto\api\platform.h|25|fatal error: cstddef: No such file or directory|

which is pointing to

#include <cstddef>

in platform.h

What’s going on?

Where? In embitz or codeblocks?

Corrupt project file, is my guess

its in embitz.

After a little googling, a solution popped up that suggested renaming .c files to .cpp. The only .c file I had was some wii nunchuck code I was looking at, which had been sitting in my project for a few days now (couldn’t get it working but never removed it). Anyway I removed it from the project and everything is fine again.
Strange how it would suddenly cause an issue like that.

Exit, reopen project. I am afraid your project file might have gotten corrupted

The issue here is probably a C file including a C++ header file (whether directly or indirectly) that’s including cstddef.
If the compiler swtiches into C mode it’ll probably start looking for angle-bracket includes from C’s point of view and C doesn’t have a cstddef in its standard library. (C++'s cstddef is C’s stddef.)

It’s best not to mix C and C++ if you can avoid it, the semantic rules are quite different in places and getting them to work together often requires glue code and workarounds (like #if defined(__cplusplus) and extern "C" {).

2 Likes