外部模板DLL和程序(crypto ++)

| 我已经将Crypto ++与VS2005和VS2010一起使用了一段时间。但是最近我需要将它直接用于和应用程序。当我将其编译为DLL时,相同的代码可以正常编译,而作为应用程序编译时,则不会编译。 这是产生误差的最小样本是这个(基于
cryptopp561\\algparam.h:301 CryptoPP::AlgorithmParametersTemplate
class Base 
{
protected:
    virtual void MoveInto(void *p) const = 0;
};

template<class T>
class Test: public Base
{
public:
    void MoveInto(void * buffer) const
    {
        Test<T> *x = new(buffer) Test<T>(*this);
    }
};

extern template class Test<bool>;
编译参数是相同的,唯一的区别是项目中的配置类型(\“ Application(.exe)\”生成错误,而\“ Dynamic Library(.dll)\”则不会)。 这是编译器错误:
main.h(15): error C2061: syntax error : identifier \'buffer\'
      main.h(14) : while compiling class template member function \'void Test<T>::MoveInto(void *) const\'
      with
      [
          T=bool
      ]
      main.h(20) : see reference to class template instantiation \'Test<T>\' being compiled
      with
      [
          T=bool
      ]
它似乎仅在有继承的情况下发生。在
class Test
声明中省略
: public Base
可使错误消失。 编辑: 问题出在标头中,该标头定义了用于ѭ5的调试版本,但未声明放置新版本。     
已邀请:
        您是否
#include <new>
,它是声明新放置的头文件?     
        有趣的是,外部模板会告诉编译器在某些时候不要实例化,因此第二个错误对我来说没有意义。您确定您的编译器支持extern模板吗?如果您执行相反的显式实例化,该怎么办:
template class Test<bool>;
    

要回复问题请先登录注册