From: Adam Maj Newsgroups: comp.os.msdos.djgpp Subject: problem using "templates" Date: Thu, 30 Dec 1999 12:23:07 +0100 Organization: Niewodniczanski Institute of Nuclear Physics, Krakow Lines: 42 Message-ID: <386B409A.2432FDEE@ifj.edu.pl> NNTP-Posting-Host: maj.ifj.edu.pl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: pl,en,da To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi, I have serious problem, connected with using " templates" in DJGPP. I cannot use objects "static", because this leads to errors. Here is small example of program "TEST. CC", that is causing errors: #include template class my_class { public : static char* str; }; template char* my_class::str="abc"; main() { cerr << my_class::str << endl; } Here is announcement of error (from window "Message Window" in RHIDE) : Compiling: test.cc no errors Creating: test.exe Error: test.o: In function `main': test.cc(1) Error: undefined reference to `my_class::str' There were some errors If we will exchange declaration of variable type of variable " str" from" char*" into" int" program will work (and compile oneself) well. But I think that use of type" int" : is the only exception, when it is possible to use static variable in "template". In remaining situations program does not compile oneself, or works incorrect (when I use type" long long int" program work, but returns unsuitable value of variable "str"). How can I fix this bug ? Maybe there is (or will be) new version of GNU (or DJGPP) ? I am using version 202 If You can help, please answer. Thanks a lot Rafal Maj