Re: Problems with g++
On Sun, Jul 11, 1999 at 09:19:45AM +0200, Ralf W. Stephan wrote:
> > I'm using g++ egcs-2.91.60 and I've had some problems with
> > inclusions of a header file. For example, if I declare a variable
> > in example.h and #includes it in example.c++ and in example2.c++
> > (these two files reference that variable and #include that header
> > file), I get an error message like this:
> You seem to be using C++ like you maybe did with C.
> I'd like to advise against that.
> In a OO language, globals are bad.
?? The same problem would occur with declaring variables in .h files in C.
Your header file should prefix the declaration with extern, and then
exactly one .c file should declare it without extern.
C++ needs #ifndef/#endif to avoid duplicate class definitions.
Hamish Moffatt VK3SB (ex-VK3TYD).
CCs of replies from mailing lists are welcome.