How to fix Arduino error: 'size_t' has not been declared

Problem:

In Arduino, you see an error message like

compile_error.txt
src/main.cpp:7:48: error: 'size_t' has not been declared
void MyFunction(size_t size);

Solution

Include stddef.h where size_t is declared:

include_stddef.h
#include <stddef.h>

Add this line to the top of the file where the error occured.


Check out similar posts by category: Arduino, C/C++, Embedded, PlatformIO