.ino files not supported - help on conversion to cpp


I gave up awhile ago and am attempting again. I want to load an existing project that is Arduino based into platform IO for a Teensy 4.1…

I have done the blink function and everything in an Arduino environment and successfully did all of that. However my code is a lot more complicated than a blink function. I have multiple cpp files (converted to from .ino, will explain in next paragraph) and 2 header files. All of these files are in the src folder.

There is a pop up that says “.ino files not supported… etc…” and it has a show instruction of how to convert.

Whereby it goes on to say that you need to do #include <Arduino.h> in your main source file, which I did, then I have to declare all the functions before they’re used. Which I did, and I am still getting a not declared in this scope error regarding various functions I created.

Where do I declare these functions? If I have functions accross various cpp files, do I declare them in the file that the function is located? Or do I put them all in the main file, and does my main file have to be named “main.cpp” or will the .cpp file with “setup” and “loop” functions in it be considered the “main file” by the IDE?

Incredibly frustrating process, especially when I go on youtube and find videos of people making simple blink functions and think this encompasses all things which need to happen in order to get your Arduino code to work in Platform IO.

Either move the functions above the code that uses them, or simply declare them above, or in a common include file.

I have a “sketch” of about 600 lines of code across a couple of files that compiled and ran fine with just the renaming of the .ino and adding the #include <Arduino.h> so I agree it can be done. My old C days taught me to declare before use.

Alright, yeah I am going piece by piece, converting my Arduino file. Cause I had 6 .ino files and 1 .h file. I am inserting each one at a time as .cpp files. Its just each of the .cpp files that isn’t main has functinons that are being called in the main. Giving me tons of declaration issues. I wanted to avoid just putting them at the top, however I tried to make another .h file where all variables and functions are defined (the other .h file I started with is essentially a large .h file defining memory location hex values and for bit shifting values.

Anyway, the new .h file appears to be working so far. As it is building/compiling.

The intellisense (autocomplete, coloring etc.) only has limited supported for .ino files and .cpp files are much prefered. However, PlatformIO can still build your original .ino files without modification, just name them with the .ino extension, e.g., src/main.ino. PIO will do the internal conversion process.

Usually after the #includes but before the function code start. This is covered in Redirecting....

If you are still struggling, this small tutorial might be helpful.