【问题标题】:c++ boost 1.71 compile error C2061 syntax error: identifier 'L'c++ boost 1.71编译错误C2061语法错误:标识符'L'
【发布时间】:2019-10-04 14:33:40
【问题描述】:

我最近通过 vcpkg 升级到 Boost 1.71 x64-windows。在升级前完美编译的 Visual Studio 2017 项目中,我现在收到此错误:

2> \x64-windows\include\boost\test\tools\floating_point_comparison.hpp(60): error C2061: syntax error: identifier 'L'
2> \x64-windows\include\boost\test\tools\floating_point_comparison.hpp(68): note: see reference to class template instantiation 'boost::math::fpc::is_abstract_class_or_function<T>' being compiled
2> \x64-windows\include\boost\log\utility\formatting_ostream.hpp(562): note: see reference to function template instantiation 'boost::log::v2_mt_nt6::basic_formatting_ostream<char,std::char_traits<CharT>,std::allocator<char>> &boost::log::v2_mt_nt6::basic_formatting_ostream<CharT,std::char_traits<CharT>,std::allocator<char>>::formatted_write<_Elem>(const OtherCharT *,std::streamsize)' being compiled

不确定问题出在 Boost::Log 还是 Boost::Test 中。这是 floating_point_comparison.hpp 中的违规代码:

template<typename T>
class is_abstract_class_or_function
{
    typedef char (&Two)[2];
    template<typename U> static char test(U(*)[1]);  // <- ***
    template<typename U> static Two test(...);

public:
    static const bool value =
           !is_reference<T>::value
        && !is_void<T>::value
        && (sizeof(test<T>(0)) == sizeof(Two));
};

输出中没有与我的代码相关的错误。事实上,我从项目中删除了所有的 .cpp 源文件(只留下了头文件),但仍然出现编译错误。

【问题讨论】:

  • 我怀疑你定义了像#define U(str) L##str这样的宏
  • @immibis MSVC => 愚蠢的 UTF-16 宏,好主意:p
  • @immibis 我进一步检查了您的建议。结果是一个 MS 库 (cpprestsdk) 定义了一些与您怀疑的非常相似的东西。幸运的是,有一个禁用它的选项并且有效。如果您想发布解决方案,我很乐意接受。

标签: c++ boost


【解决方案1】:

您在某处有一个宏,类似于:#define U(str) L##str

所以U(*) 变成了L*,但U 没有变成L

【讨论】:

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