C++ 加密++;在algparam.h中给出编译器错误

C++ 加密++;在algparam.h中给出编译器错误,c++,crypto++,C++,Crypto++,我在一个相当大的文件中有以下几行: #include <sha.h> #include <hex.h> #包括 #包括 编译时,会引发以下编译器错误: 1>d:\work\app\tools\cryptopp\algparam.h(322): error C2061: syntax error : identifier 'buffer' 1> d:\work\app\tools\cryptopp\algparam.h(321) : whi

我在一个相当大的文件中有以下几行:

#include <sha.h>
#include <hex.h>
#包括
#包括
编译时,会引发以下编译器错误:

1>d:\work\app\tools\cryptopp\algparam.h(322): error C2061: syntax error : identifier 'buffer'
1>          d:\work\app\tools\cryptopp\algparam.h(321) : while compiling class template member function 'void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void *) const'
1>          with
1>          [
1>              T=bool
1>          ]
1>          d:\work\app\tools\cryptopp\algparam.h(329) : see reference to class template instantiation 'CryptoPP::AlgorithmParametersTemplate<T>' being compiled
1>          with
1>          [
1>              T=bool
1>          ]
1>d:\work\app\tools\cryptopp\algparam.h(322):错误C2061:语法错误:标识符“buffer”
1> d:\work\app\tools\cryptopp\algparam.h(321):编译类模板成员函数“void cryptopp::AlgorithmParametersTemplate::MoveInto(void*)const”时
1> 与
1>          [
1> T=bool
1>          ]
1> d:\work\app\tools\cryptopp\algparam.h(329):请参阅正在编译的类模板实例化'cryptopp::AlgorithmParametersTemplate'的参考
1> 与
1>          [
1> T=bool
1>          ]
我很确定我忘了什么,但我不确定是什么。如果我不包括hex.h,我不会有任何问题,我会得到一个SHA256哈希值,但是当我包括hex.h时,会弹出错误

编辑

如果有人想知道,请参阅Crypto++工具包的algparam.h:

void MoveInto(void *buffer) const //<=== line 320
{
    AlgorithmParametersTemplate<T>* p = new(buffer)
    AlgorithmParametersTemplate<T>(*this);
}

CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<bool>; // <== line 329

void MoveInto(void*buffer)const/我通过临时取消定义
new
修复了这个问题,它被定义为一些额外调试代码的宏

#pragma push_macro("new")
#undef new
/* #includes for Crypto++ go here */
#pragma pop_macro("new")

如果在具有MFC支持的Visual Studio项目中包含Crypto++,则此错误可能由以下行引起:

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

确保将其删除或注释掉。

这是错误的全部文本吗?还有其他错误吗?您引用的
InitEngine
代码与此错误之间是否存在任何链接?错误文本不引用它或其中的任何内容。注释
InitEngine
out时是否仍会发生错误?否,没有任何代码引用此
MoveInto
函数。然而,hex.h似乎包括basecode.h,其中包括algparam.h。似乎每当包含algparam.h时,它都会失败。是的,如果我在
InitEngine
out中注释代码,它仍然会发生。如果
InitEngine
不相关,请将其从问题中删除。现在,如果你注释掉除两个之外的所有内容,它会失败吗?如果您只保留
hex.h
,会怎么样?如果我只包含
hex.h
,它会失败,并出现相同的错误。@AngeloGeels:该行不在MFC标题中。它被添加到MFC向导生成的
.cpp
文件中。啊,我明白了-仍然,如果我上面的回答也解决了这个问题,那么评论它可能不是一个好主意。@AngeloGeels:
DEBUG_NEW
覆盖MFC调试的
NEW
操作符:因此我不确定您的解决方案是否也能工作。我知道它能做到这一点-但是您不能确定Crypto++是否能处理MFC的
DEBUG_NEW
正确地我不知道你为什么认为你的解决方案更好。如果有什么不同的话,它会通过注释掉这些内容来禁用MFC进行的所有有用的内存泄漏检查。