www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/30/18:25:19

From: jmarco AT cnct DOT com (John Panettiere)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: template function not linking
Date: Mon, 30 Dec 1996 08:06:48 GMT
Organization: The Internet Conection
Lines: 67
Message-ID: <5a80nr$gpq@news2.cnct.com>
References: <5a4srt$2i4 AT news2 DOT cnct DOT com>
NNTP-Posting-Host: nj-dialup230.cnct.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Never mind, I found the problem, sorry for time & space wasted. . .

John Panettiere


jmarco AT cnct DOT com (John Panettiere) wrote:

>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