What's wrong with the call functions of type void in PlatformIO?

Use PlatformIO for working with Arduino. When using the sketch function of type void, the compiler generates an error: 'screen_function' was not declared in this scope [20, 20]

here is the sketch:

#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>

#define button 2 
#define screenPower 9 //the pin responsible for power display
boolean powerFlag = 0; //flag switching power supply 

LiquidCrystal_PCF8574 lcd(0x27);

void setup(){
 pinMode(screenPower, OUTPUT);
 pinMode(button, INPUT_PULLUP);
}

void loop(){
 screen_function(); //here throws the error
}

void screen_function(){ //on-off the display via the control pin
 if (digitalRead(button) == LOW){ //use the lift to the ground, the signal is inverted
 powerFlag = !powerFlag;
 digitalWrite(screenPower, powerFlag); 
}
}
March 25th 20 at 13:31
1 answer
March 25th 20 at 13:33
Solution
You need to add a forward Declaration or to define function before its first use.

void screen_function(); // Declaration
// ...
void loop(){
 screen_function(); // first use
}
// ...

void screen_function()
{
// ... definition
}
Added the function definition as you wrote, it worked, thank you very much - maxine commented on March 25th 20 at 13:36

Find more questions by tags C++Arduino