www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/29/00:42:09

From: jmarco AT cnct DOT com (John Panettiere)
Newsgroups: comp.os.msdos.djgpp
Subject: template function not linking
Date: Sun, 29 Dec 1996 03:42:30 GMT
Organization: The Internet Conection
Lines: 58
Message-ID: <5a4srt$2i4@news2.cnct.com>
NNTP-Posting-Host: nj-dialup236.cnct.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello, all.  I am using template functions for the
first time, and I seem to be having some problems
linking.  This is more accurately a C++ question,
but I'm posting it here in case the particular
behavior of djgpp is an issue.  In a header file,
I declare:


[generic.h]:
template <class Item> void GenericAlgorithm(Item *,
                                                Item *,
                                                unsigned long,
                                                unsigned long);



This same template function is defined, using the
"Item" class placeholder indicated in the prototype,
in a separate [generic.cpp] file.  Next, in another
file [test.cpp] I have:



[test.cpp]

#include "generic.h"
#define VALUE 2

ClassA arrayOfClassA[2];
ClassA * pointerToClassA;

GenericAlgorithm(arrayOfClassA,
                            pointerToClassA,
                            (unsigned long) 4 << VALUE,
                            (unsigned long) VALUE);



[generic.cpp] and [test.cpp] compile just fine, but
at link time I'm told that it can't find the
definition of



GenericAlgorithm(ClassA *,
                            ClassA *,
                            unsigned long,
                            unsigned long);



even though I am linking together [test.o] and
[generic.o] in that order.  Can anyone tell me 
what I'm doing wrong?  Thank you!

John Panettiere


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019