[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Problems with g++

Hi folks:

      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:

   /tmp/cc8IeZSz.o(.bss+0x0): multiple definition of `global'
   /tmp/ccovurMu.o(.bss+0x0): first defined here
   collect2: ld returned 1 exit status     

      I tried to use something like this:

   #ifndef GLOBAL
   int global;
   #define GLOBAL

   in the header file, but the #ifndef is not working. 

   What can I do to declare all the global variables in the
header file and avoid the redefinition of them, when the
header is #included by more than one .c++ file? 

   Thanks in advance.
Ivan J. Varzinczak - (mailto: ivan@inf.ufpr.br)
Bolsista PET/CAPES - Depto. de Informatica - UFPR
Curitiba - Parana - Brasil
Phone: +55 (041) 347-3240 - 267-5244 r.315


Reply to: