[SOLVED]Calling a function of the main in a seperate file

To have all nice and clean I wanted the code in seperate files.


void seperateFunction();
void functionInMain();

void setup() {

void loop() {

void functionInMain(){
  // do stuff


void seperateFunction(){

But I get an error. It seems that seperate.cpp is not seeing the functionInMain().
Both files are in the same directory and I'm using VSCode/Platformio.
How can I fix this? Do you have a solution for this?

your seperate.cpp doesn't have a declaration for functionMain().

void functionInMain();

the declaration tells the compiler what argument and argument types are required and the return type of the function.

the arduino IDE does some of this stuff for you if it is an .ino file

such declarations of functions, constants and possibly (not recomended) global variables are placed in a .h file that is included in other files that use those functions.

See Reply #3 Here.

your seperate.cpp doesn’t have a declaration for functionMain().

Thanks. This was the missing thing.

And thanks for the explanation.

Also thank you gfvalvo for your information.