0

We have a C++ header file containing lot of class templates say myclasstemplates.h Say there are two source files a.cpp and b.cpp which include this header file. I generate a static library a.lib, out of a.cpp using Intel compiler. Then I generate a dynamic library using b.cpp with MSVC compiler and link the static library(a.lib) into this dynamic library.

I define a statement like this in a.cpp,

#ifdef __INTEL_COMPILER
cout<<"I am compiled by icc";
#else
cout<<"I am compiled by msvc";
#endif

Note: __INTEL_COMPILER is defined for Intel compiler and I have verified it.

When I run my dynamic library, I see "I am compiled by msvc" printed which I do not seem to understand. The basic question is whether the template code for the class generated during the compilation of a.cpp and b.cpp overridden during the linking stage of dynamic library generation?

Thanks

  • Add to your `cout` statement __FILE__ and __LINE__, see http://stackoverflow.com/questions/597078/file-line-and-function-usage-in-c – fghj Apr 23 '16 at 06:02
  • The question is why the template code used by the static library(built with intel compiler) is actually being linked to the code generated by the dynamic library. – user4177870 Apr 23 '16 at 17:44

0 Answers0