我遇到了与 Crypto++ giving a compiler error in algparam.h 相同的错误使用 Crypto++ 编译游戏时。错误是:
Error C2061: syntax error : identifier 'buffer' (at line 397)
这是代码。它从第 390 行开始到第 411 行结束。
#if defined(DEBUG_NEW) && (_MSC_VER >= 1300)
# pragma push_macro("new")
# undef new
#endif
void MoveInto(void *buffer) const
{
AlgorithmParametersTemplate<T>* p = new(buffer) AlgorithmParametersTemplate<T>(*this);
CRYPTOPP_UNUSED(p); // silence warning
}
#if defined(DEBUG_NEW) && (_MSC_VER >= 1300)
# pragma pop_macro("new")
#endif
protected:
T m_value;
};
CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<bool>;
CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<int>;
CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<ConstByteArrayParameter>;
问题是什么,我该如何解决?
这是我使用的库:
- boost 1.67(也尝试过 1.63)
- sqlapi++
- 营地
- mysqlcppconns
这是错误信息:
1>c:\local\cryptopp\algparam.h(397): error C2061: syntax error: identifier 'buffer'
1>c:\local\cryptopp\algparam.h(396): note: while compiling class template member function 'void CryptoPP::AlgorithmParametersTemplate<CryptoPP::ConstByteArrayParameter>::MoveInto(void *) const'
1>c:\local\cryptopp\algparam.h(411): note: see reference to class template instantiation 'CryptoPP::AlgorithmParametersTemplate<CryptoPP::ConstByteArrayParameter>' being compiled
最佳答案
这是您在 algparam.h
中遇到问题的函数:
395 void MoveInto(void *buffer) const
396 {
397 AlgorithmParametersTemplate<T>* p = new(buffer) AlgorithmParametersTemplate<T>(*this);
398 CRYPTOPP_UNUSED(p); // silence warning
399 }
我怀疑您正在使用的其他库之一与 new
上的定义混淆。
我相信您需要编译源文件,而不是生成目标文件,您需要使用 /P (Preprocess to a File)或 /E (Preprocess to stdout) .处理完文件后,请查看 new
的定义。从那里回到正在更改它的图书馆。
在您说的评论中您还使用:
- boost 1.67(也尝试过 1.63)
- sqlapi++
- 营地
- mysqlcppconns
Boost 有时会做一些不寻常的事情,我怀疑是 boost 的问题。
关于c++ - 错误 C2061 : syntax error : identifier 'buffer' when compiling algparam. h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50192917/