Declaring a function after invoking it?

The last time I taught a course in IoT, I was able to write C++ functions after the point where they were invoked in a file. I think there was some sort of system, maybe Wiring?, that would allow that.

But now, that doesn't seem to work. I can create a .h file quickly enough, but I do miss that flexibility. What happened to it?

Using a function before implementation is a feature of the Wiring preprocessor, which is only used for .ino files, of which there can only be one per firmware application.

We recommend using a forward declaration, which is the function prototype with no body, just a semicolon before it is used, then it can be implemented later in the file.

1 Like

Hi, you can write a forward declaration at the top of your .cpp file, no header file needed.

1 Like

Got it, thanks! Oh, and also thanks for your SSD_1306 library, it's working like a charm :grinning: