B
Bob Altman
Hi all,
I have a project that contains a templated routine. This same project contains
code that tries to construct an instance of that templated routine. I have the
following bits and pieces:
Something.h
// Just the signature, not the implementation
template <class T> void MyTemplatedRoutine(T arg);
MyTemplatedRoutine.cpp
// Implementation
template <class T> void MyTemplatedRoutine(T arg)
{ <implementation> }
X.cpp
// Try to use it
#include "Something.h"
int x = 5;
a = MyTemplatedRoutine(x);
The linker complains that it can't find void __cdecl
MyTemplatedRoutine<int>(int). I need to implement the templated routine in a
code file rather than in the header file because it contains references to
static module-level data declared in the code file. What do I need to do to
make the linker happy?
TIA - Bob
I have a project that contains a templated routine. This same project contains
code that tries to construct an instance of that templated routine. I have the
following bits and pieces:
Something.h
// Just the signature, not the implementation
template <class T> void MyTemplatedRoutine(T arg);
MyTemplatedRoutine.cpp
// Implementation
template <class T> void MyTemplatedRoutine(T arg)
{ <implementation> }
X.cpp
// Try to use it
#include "Something.h"
int x = 5;
a = MyTemplatedRoutine(x);
The linker complains that it can't find void __cdecl
MyTemplatedRoutine<int>(int). I need to implement the templated routine in a
code file rather than in the header file because it contains references to
static module-level data declared in the code file. What do I need to do to
make the linker happy?
TIA - Bob