Moving code from Arduino IDE to PlatformIO: dealing with requirements for forward declarations

Hi All

I am working with some code which was originally written using the Arduino IDE and I am wanting to work on it using PlatformIO. (in VS Code)

The Arduino IDE does not force forward declaration of functions, and the order in which the functions have been declared in the code is somewhat random and there are about 100 functions declared. (it is a big file).

PlatformIO thus throws many “not declared in this scope” errors.

Is there a tool available in PlatformIO or elsewhere that can re-order the function declarations to be compatible with what PlatformIO expects or is this something which needs to done manually ?

Many Thanks


100 functions in a single file? That’s heavy.

Why not take it as an occasion to split the file into several ones? It will be even more work than creating the forwared declarations manually, but it will be so much easier to manage and quickly pay off.

1 Like

:slight_smile: You’re right I totally agree. I was hoping VS Code might have had an addon/plugin which extracted all of the function declarations so I could put them all in a header file (.h). Any such tool avaialble?

But of course eventually this beast needs taming.

1 Like

This is an often requested feature for VSCode’s C++ extension… but is yet to be implemented. :frowning: The nearest I know to doing this is this extension, which does the opposite… creates the skeleton implementation from a prototype… but it is early days, so perhaps the author will add the reverse functionality…