c++ - 错误 C2061 : syntax error : identifier 'buffer' when compiling algparam. h

标签 c++ boost compilation crypto++ database-connection

我遇到了与 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/

相关文章:

c++ - 用 nullptr 交换流缓冲区来模拟移动?

c++ - 提升图宽度优先搜索前身编译错误

c++ - 在 Windows 10 TP 上使用 VS-2015 CTP 5 和 Python 3.5a 编译 boost-python 教程

c++ - 来自模板化迭代器的 boost::iterator_range

Swift - 使用输入参数编译程序

c++ - 如何在 Visual C++ 2012 中 sleep 不受系统时钟调整影响的固定时间

c++ - 令人困惑的指针声明

c++ - 将 float ( double )转换为字符串

angular - index.ts 不是编译输出的一部分

c++ - ';' token 之前的错误 : expected ',' , ')' 或 '='