【问题标题】:Error C2061: syntax error : identifier 'buffer' when compiling algparam.h错误 C2061:语法错误:编译 algparam.h 时的标识符“缓冲区”
【发布时间】:2018-05-05 18:46:00
【问题描述】:

在使用 Crypto++ 编译游戏时,我遇到了与 Crypto++ giving a compiler error in algparam.h 相同的错误。错误是:

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

有什么问题,我该如何解决?


这是我使用的库:

  • 提升 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

【问题讨论】:

  • 您使用的是什么版本的库?你是如何建造图书馆的?你是如何编译和链接你的程序的?
  • 我在游戏中使用cryptopp 7.0 - Debug Mode。在编译中,我使用了所有这些库:boost 1.67 (tried 1.63 too), sqlapi++, camp, mysqlcppconns。由于源文件不是我的,所以我有很多警告,但所有这些警告都可以。如果需要,这是 github 的链接:Click Here
  • 好吧,我不确定问题出在哪里。您可能应该从显示完整错误开始,而不仅仅是“错误 C2061:语法错误:标识符 'buffer'(第 397 行)”。我想您需要将其减少到minimal, complete, and verifiable example。如果我不得不冒险猜测,那是意外的编译器切换或与其他库之一的异常交互。

标签: c++ boost compilation crypto++ mysqlconnection


【解决方案1】:

这是您遇到问题的函数,来自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 的定义。从那里工作回到正在改变它的图书馆。

在你说你也使用的 cmets 中:

  • 提升 1.67(也试过 1.63)
  • sqlapi++
  • 营地
  • mysqlcppconns

Boost 有时会做一些不寻常的事情,我怀疑 Boost 是问题所在。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多