From: Matthew Mastracci Newsgroups: comp.os.msdos.djgpp Subject: Template difficulties... (GNU's method?) Date: Wed, 2 Apr 1997 09:01:33 -0700 Organization: The University of Calgary Lines: 76 Message-ID: Reply-To: Matthew Mastracci NNTP-Posting-Host: mmastrac AT acs2 DOT acs DOT ucalgary DOT ca Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I've been trying to compile some classes that use templates with DJGPP and I've had no luck. Each time I get unresolved reference errors when the linked tries to create the executable. I've read GNU's explanation about template instantiation (sp?), but it says that one of my options with creating templates is to just pretend that the compiler works with them properly (at the expense of unnecessarily duplicated code, however). I haven't tried the #interface/#implementation method mentioned in the info file, but I want the code to be fairly portable, so it's not really an option. The code is similar to the following, which compiles with the same errors: -- external.h --: #ifndef EXT #define EXT template class Test { public: Test(T Value); void Print(void); T Storage; }; // Is this next line needed? (ie: so it's not // typedef class Test TestInt; #endif -- external.cc --: #include "external.h" #include template Test::Test(T Value) { Storage = Value; } template void Test::Print(void) { cout << Storage; } -- main.cc --: #include "external.h" int main(void) { // Or TestInt, if line in external.h is uncommented Test a(24); a.Print(); return 0; } I can't see any real errors in this code, and I think it would compile correctly under Visual C++. I'm looking for a solution that uses the compiler flags rather than one that uses other methods. Thanks in advance, /\/\att /\/\astracci mmastrac AT acs DOT ucalgary DOT ca GCS/GE d- s+:+ a--- C++++ UA P+ L E-- W+ N++ o K+ w+ O M- V PS++ PE++ Y+ PGP t+++ 5+++ X++ R++ tv+ b+++ DI++++ I G++ e h r* z?