I have the following code and am getting
"error: void value not ignored as it ought to be
int ab = findActiveBlock();"
I would understand this error if findActiveBlock was set to void but it is returning an int? Please help
void updateActiveBlock() {
int ab = findActiveBlock();
//code using ab//
}
int findActiveBlock() {
for (int i = 0; i < BLOCKCOUNT; i++) {
if(blocks[i].active) {
return i;
}
}
return 1;
}
additional info: this is C, "blocks[]" is an array of structs.
I would make a wild guess that your findActiveBlock
is actually pre-declared somewhere above as a void
-returning function. You simply forgot to update that declaration to make it match the definition.
PS As an additional side note: ()
parameter lists is an obsolescent feature in C. For functions that have no parameters, prefer to use (void)
in their declarations.
Just a stab in the dark, but is *.active a function? If so it would need parentheses.
int findActiveBlock() {
for (int i = 0; i < BLOCKCOUNT; i++) {
if(blocks[i].active()) { //added parentheses to active
return i;
}
}
return 1;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.