void value not ignored as it ought to be

i am getting this error when compiling with g++

where can I find documentation on this? I've look all over google without luck.
It means a function is declared to return nothing (void) but you are assigning the return code to a variable.

eg,

1
2
3
4
5
6
7
void foo() {
   // do stuff
}

int main() {
   int x = foo();  // error, foo returns nothing
}

thanks. do you know where it look up to information? i dont know where the error message documentation is
Not off the top of my head. I'd start here:

http://gcc.gnu.org/onlinedocs/

(I have not looked in detail at the documentation to see if they have compiler error messages).
Topic archived. No new replies allowed.