Script started on Fri 01 Sep 2006 02:49:18 PM EDT I tried to compile a program, but got a strange error. It used to work, but I have not compiled it in years. Here is a small program that demonstrates the problem, and replicates the error message. carmaux$ cat str_test.cc #include #include void printme(string mystr) { cout << mystr << endl; } int main() { printme("hello"); return 0; } carmaux$ carmaux$ g++ str_test.cc str_test.cc:5: error: variable or field `printme ' declared void str_test.cc:5: error: `string ' was not declared in this scope str_test.cc:5: error: expected `, ' or `; ' before `{ ' token str_test.cc: In function `int main() ': str_test.cc:10: error: `printme ' cannot be used as a function carmaux$ Usually, the first error message is the most relevant. But what is wrong with making a function void? The second error message is not helpful, either. It makes me think there is a problem with the "string" include. I tried "string.h", but it did not help. I finally realized that this problem stems from the same error that I've had before--the "using" line is not there. I remember that years ago some compilers required this directive, but the one I used (g++) actually gave me an error. That was about 1999. Since about 2002, the g++ compiler (OK, at least my version) required using it. But I still leave it out. The old programs are worse about this--the program that I was trying to compile was a long one that I've used for years. I had to recompile it since the executable calls a library file that my current OS (Ubuntu) does not have, probably since it includes a newer version. Here is the fixed version. As you can see below, it compiles and runs just fine. carmaux$ cat str_test.cc #include #include using namespace std; void printme(string mystr) { cout << mystr << endl; } int main() { printme("hello"); return 0; } carmaux$ g++ str_test.cc carmaux$ ./a.out hello carmaux$ exit Script done on Fri 01 Sep 2006 03:01:48 PM EDT -- Michael Weeks, copyright 2006, 2009