Reputation: 999
Simply asked: What is going wrong here?!
class c {
public:
static void v() {
int var = 0;
}
static int i() {
return 1;
}
};
c::i(); // Throws error message
c::v(); // Also throws error message
void setup() {
}
void loop() {
}
The error message(s) are:
Compiling sketch...
/tmp/698769749/CompilingTests/CompilingTests.ino:12:7: error: expected constructor, destructor, or type conversion before ';' token
c::i();
^
/tmp/698769749/CompilingTests/CompilingTests.ino:13:7: error: expected constructor, destructor, or type conversion before ';' token
c::v();
^
exit status 1
What should this error message tell me?
Upvotes: 1
Views: 2468
Reputation: 23792
One of the problems that stands out is that your functions don't have public access.
Upvotes: 1
Reputation: 40060
Statements c::i()
and c::v()
are not allowed in the global scope, they should be enclosed inside a function. Also, those static member functions should be declared public
in order to be accessible outside c
:
struct c {
static void v() {
int var = 0;
}
static int i() {
return 1;
}
};
void g()
{
c::i();
c::v();
}
void setup() {
}
void loop() {
}
demo: https://godbolt.org/z/whiDHh
Upvotes: 3