I’m trying to go through a few books to learn Arduino programming and really like PlatformIO IDE but I keep running into issues with code that won’t work in PlatformIO but will work in the regular Arduino IDE. It’s a simple program that flashes the built in LED, when I build it i get an “error: ‘flash’ was not declared in this scope”.

You need to declare flash() before you can use it, this is called “forward declaration”. Just add a line void flash(int numFlashes, int d); before loop() and then you can put the complete function anywhere in the code. Adruino IDE does some magic when converting ino to C++ but with PIO you have to write normal C++.