PlatformIO Community

Multi file in /include and /src call Arduino function

Hi, I meet some diffcult when try to create a project having multi files in /src and /include folder.
I have see some discuss but they don’t solve my problem…
For simple, I create main.cpp and test.c in /src folder and test.h in /include.
and their content is

main.cpp

test.c

test.h

but when I build the project, an error saied ‘Serial’ undeclared. As I known, boath Serial and pinMode, LED_BUILTIN, millis() are Arduino built in function. Why only Serial is unrecognized and how to solve it…
by the way, my platform is ESP32, but I also tried Arduino UNO and they don’t work neither…
Thanks everyone

…Calling into member functions of C++ objects, such as Serial, won’t work from .c files. C has no notion of classes.

Either do test.cpp or create a C++ to C wrapper function as explained in this FAQ.

Ok,Thanks for the rely. that really helps me.