Struct as argument
i have following struct:
struct key {
int board;
int value;
int type;
};
and need create function
void assigntoboard(key &obj1, analogmultiplexer &obj2) {
//this function assigns table object multiplexer board, every key mapped.
}
that receives array of struct objects , assigns analogmultiplexer object. problem when compile get:
zanella_launchpad:18: error: variable or field 'assigntoboard' declared void
zanella_launchpad:18: error: 'key' not declared in scope
zanella_launchpad:18: error: 'obj1' not declared in scope
zanella_launchpad:18: error: expected primary-expression before '&' token
zanella_launchpad:18: error: 'obj2' not declared in scope
but when take
void assigntoboard(analogmultiplexer &obj2) {
(without key object) compiles.
i don't understand i'm doing wrong since declared 'key' before void assigntoboard.
struct key {
int board;
int value;
int type;
};
and need create function
void assigntoboard(key &obj1, analogmultiplexer &obj2) {
//this function assigns table object multiplexer board, every key mapped.
}
that receives array of struct objects , assigns analogmultiplexer object. problem when compile get:
zanella_launchpad:18: error: variable or field 'assigntoboard' declared void
zanella_launchpad:18: error: 'key' not declared in scope
zanella_launchpad:18: error: 'obj1' not declared in scope
zanella_launchpad:18: error: expected primary-expression before '&' token
zanella_launchpad:18: error: 'obj2' not declared in scope
but when take
void assigntoboard(analogmultiplexer &obj2) {
(without key object) compiles.
i don't understand i'm doing wrong since declared 'key' before void assigntoboard.
try putting struct header file , #include-ing it. it's auto-generated function prototypes ide inserts that's causing error.
Arduino Forum > Using Arduino > Programming Questions > Struct as argument
arduino
Comments
Post a Comment