Main ino file (1393854.demo1.ino)
struct ABC
{
char a[20];
int b;
float c;
};
ABC abc = { "text", 3, PI };
void setup()
{
Serial.begin(115200);
printABC(abc);
}
void loop()
{
// put your main code here, to run repeatedly:
}
Secondary ino file (functions1.ino)
void printABC(ABC x)
{
Serial.println(x.a);
Serial.println(x.b);
Serial.println(x.c);
}
This compiles without problems. Now move setup() en loop() from the main ino file to the secondary file.
Main ino file (1393854.demo1.ino)
struct ABC
{
char a[20];
int b;
float c;
};
ABC abc = { "text", 3, PI };
Secondary ino file (functions1.ino)
void printABC(ABC x)
{
Serial.println(x.a);
Serial.println(x.b);
Serial.println(x.c);
}
void setup()
{
Serial.begin(115200);
printABC(abc);
}
void loop()
{
// put your main code here, to run repeatedly:
}
This fails to compile
C:\Users\bugge\OneDrive\Documents\Arduino\1_forum.arduino.cc\1393854\1393854.demo1\functions1.ino:1:15: error: variable or field 'printABC' declared void
void printABC(ABC x)
^~~
C:\Users\bugge\OneDrive\Documents\Arduino\1_forum.arduino.cc\1393854\1393854.demo1\functions1.ino:1:15: error: 'ABC' was not declared in this scope
C:\Users\bugge\OneDrive\Documents\Arduino\1_forum.arduino.cc\1393854\1393854.demo1\functions1.ino:1:15: note: suggested alternative: 'ADC'
void printABC(ABC x)
^~~
ADC
exit status 1
Compilation error: variable or field 'printABC' declared void
The ino.cpp file
#include <Arduino.h>
#line 1 "C:\\Users\\bugge\\OneDrive\\Documents\\Arduino\\1_forum.arduino.cc\\1393854\\1393854.demo1\\functions1.ino"
void printABC(ABC x);
#line 8 "C:\\Users\\bugge\\OneDrive\\Documents\\Arduino\\1_forum.arduino.cc\\1393854\\1393854.demo1\\functions1.ino"
void setup();
#line 14 "C:\\Users\\bugge\\OneDrive\\Documents\\Arduino\\1_forum.arduino.cc\\1393854\\1393854.demo1\\functions1.ino"
void loop();
#line 0 "C:\\Users\\bugge\\OneDrive\\Documents\\Arduino\\1_forum.arduino.cc\\1393854\\1393854.demo1\\functions1.ino"
#line 1 "C:\\Users\\bugge\\OneDrive\\Documents\\Arduino\\1_forum.arduino.cc\\1393854\\1393854.demo1\\1393854.demo1.ino"
struct ABC
{
char a[20];
int b;
float c;
};
ABC abc = { "text", 3, PI };
#line 1 "C:\\Users\\bugge\\OneDrive\\Documents\\Arduino\\1_forum.arduino.cc\\1393854\\1393854.demo1\\functions1.ino"
void printABC(ABC x)
{
Serial.println(x.a);
Serial.println(x.b);
Serial.println(x.c);
}
void setup()
{
Serial.begin(115200);
printABC(abc);
}
void loop()
{
// put your main code here, to run repeatedly:
}
I do not have the understanding of the internals of the builder but I'm reasonably sure that I understand the idea behind it. I hope that I did not make a stupid mistake in above ![]()
When I encountered the issue it was in a sketch with far more ino files and they were "numbered" like main.ino, a_setup.ino, b_loop.ino etc. The above is a simple simulation.
Here is one that I'm aware of: Generated function prototype injected before declaration of custom parameter type · Issue #2696 · arduino/arduino-cli · GitHub. The builder can at occasion not even process a single ino file correctly. I've verified it just now.