I have the following bit of legacy C++ code that does not compile:
#include <stdio.h> #include <iostream> extern ostream *debug;
GCC (g++) complains: ‘expected initializer before ‘*’ token’
Looking around it seems more common to declare these as external references, like this:
extern ostream& debug;
Why is a pointer not valid, but a reference is in this situation?
SOLUTION:
The real problem, as mentioned below is that the std:: namespace specifier is missing. Apparently, this was common in older C++ code.
Yes, you can declare a pointer using extern. Your error is most likely you forgot to qualify using
std:::