Tonight I had something strange.
I have a class named Detection in a file named Detection.h.
In my main ico file, I wanted to have a function take it as a parameter.
void foo(Detection& d) {
d.whatever();
}
However the above gave me an error about Decoration being unknown.
However, if I rewrote it like so:
Detection d:
void foo() { //I assign to the global variable then call foo()
d.whatever();
}
This compiles and works. So why can't it find the symbol as a global variable but not as a parameter?
As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming category of the forum
Sigh, another !^#%^&!#% snippet...
Fine.
You mean a "function take an instance of it as a parameter, yes?
Decoration or Detection?
That makes no sense whatsoever.
The following non snippet compiles just fine.
class Detection {
public:
Detection() {};
void whatever(void) { Serial.println("Whatever"); };
};
void foo(Detection& d) {
d.whatever();
}
void setup(void) {
Detection xyz;
Serial.begin(115200);
foo(xyz);
}
void loop(void) {
}
I know I'm light on the details. I tried to make a short example program to reproduce the problem in short amount of code. But my short version compiled fine.
I'll supply more details soon.
system
Closed
July 6, 2025, 11:02am
6
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.