J
john_owens
I have a templated function called splitAndSegment (templated on the
datatype). It's declared in a header file. I then include that header
file in two separate cpp files and link them separately. Both files
use the function, and both use the same instantiation of the function
(datatype int). Thus they both instantiate the function in their
separate obj files. I declare the function inline to prevent linking
problems, but I get linking problems anyway.
template<typename T>
inline
void splitAndSegment(T * in, unsigned int * temp1, T * temp2,
Flag * ihflags, Flag * ihtflags,
const Flag * cmpflags)
{ definition here ... }
Linking errors:
Linking...
test_app.obj : error LNK2005:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs_0 already defined in
sort_app.obj
test_app.obj : error LNK2005:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs already defined in
sort_app.obj
test_app.obj : warning LNK4006:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs_0 already defined in
sort_app.obj; second definition ignored
test_app.obj : warning LNK4006:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs already defined in
sort_app.obj; second definition ignored
I'm totally puzzled and would appreciate any help on figuring out why
this occurs. It's on MS Dev Studio v. 7.10.3077 (I believe it's VS
2003).
JDO
datatype). It's declared in a header file. I then include that header
file in two separate cpp files and link them separately. Both files
use the function, and both use the same instantiation of the function
(datatype int). Thus they both instantiate the function in their
separate obj files. I declare the function inline to prevent linking
problems, but I get linking problems anyway.
template<typename T>
inline
void splitAndSegment(T * in, unsigned int * temp1, T * temp2,
Flag * ihflags, Flag * ihtflags,
const Flag * cmpflags)
{ definition here ... }
Linking errors:
Linking...
test_app.obj : error LNK2005:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs_0 already defined in
sort_app.obj
test_app.obj : error LNK2005:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs already defined in
sort_app.obj
test_app.obj : warning LNK4006:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs_0 already defined in
sort_app.obj; second definition ignored
test_app.obj : warning LNK4006:
__ZZ15splitAndSegmentIiEvPT_PjS1_PiS3_PKiEs already defined in
sort_app.obj; second definition ignored
I'm totally puzzled and would appreciate any help on figuring out why
this occurs. It's on MS Dev Studio v. 7.10.3077 (I believe it's VS
2003).
JDO