This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: C++ undefined symbol


>-----Original Message-----
>From: Olivier Garbil [mailto:ogarbil@palmware.fr]
>Sent: 26 March 2001 10:38

>I have done a back end for our target (a virtual machine) on gcc-2.95.2.
>The C works fine but not the C++. If I try to compile this code:
>
>class a
>{
> public:
>   static long i;
>   void foo() {i = 0;}
>};
>
>main()
>{
> a* A = new a;
> A->foo();
>}
>
>The i attributs is correctly use (as __static_1a_i) but never declared
>in the assembler code produced by g++.

  Your C++ code is bad.  A static member of a class must be explicitly
defined as well as declared.  Add the line

long a::i;

somewhere in there and all should be ok.

      DaveK
-- 
 All your base are belong to us!


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]