Crypto++ giving a compiler error in algparam.h

孤者浪人 提交于 2019-12-14 04:17:22

问题


I have the following lines in a rather large file:

#include <sha.h>
#include <hex.h>

Which, when compiled, throws this compiler error:

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>          ]

I'm pretty sure I'm forgetting something, but I'm not sure what. If I don't include hex.h, I don't have any problems and I get a SHA256 hash just fine, but when I do include hex.h, the error pops up.

Edit

In case anyone wonders, from algparam.h of Crypto++ toolkit:

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

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

Edit: Removed unrelated code


回答1:


I fixed the problem by temporarily undefining new, which was defined as a macro to some extra debugging code.

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



回答2:


If you're including Crypto++ in a Visual Studio project with MFC support, this error might be caused by this line:

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

Make sure to remove it or comment it out.



来源:https://stackoverflow.com/questions/15203562/crypto-giving-a-compiler-error-in-algparam-h

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!