• 解决问题error: reference to ‘byte‘ is ambiguous


    问题描述

    在引入头文件时编译报错。

    FAILED: CMakeFiles/untitled.dir/main.cpp.obj 
    "D:\software\Clion\CLion 2023.2.1\bin\mingw\bin\g++.exe"   -g -fdiagnostics-color=always -MD -MT CMakeFiles/untitled.dir/main.cpp.obj -MF CMakeFiles\untitled.dir\main.cpp.obj.d -o CMakeFiles/untitled.dir/main.cpp.obj -c D:/CLionProjects/untitled/main.cpp
    In file included from D:/software/Clion/CLion 2023.2.1/bin/mingw/x86_64-w64-mingw32/include/wtypes.h:8,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/x86_64-w64-mingw32/include/winscard.h:10,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/x86_64-w64-mingw32/include/windows.h:97,
                     from D:/CLionProjects/untitled/util.h:8,
                     from D:/CLionProjects/untitled/main.cpp:3:
    D:/software/Clion/CLion 2023.2.1/bin/mingw/x86_64-w64-mingw32/include/rpcndr.h:64:11: error: reference to 'byte' is ambiguous
       64 |   typedef byte cs_byte;
          |           ^~~~
    In file included from D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/memory_resource.h:38,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/string:58,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/locale_classes.h:40,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/ios_base.h:41,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/ios:44,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/ostream:40,
                     from D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/iostream:41,
                     from D:/CLionProjects/untitled/main.cpp:1:
    D:/software/Clion/CLion 2023.2.1/bin/mingw/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/cstddef:69:14: note: candidates are: 'enum class std::byte'
       69 |   enum class byte : unsigned char {};
          |              ^~~~
                ^~~~
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    解决

    大概是标准库里宏定义或者枚举或者typedef byte了,产生了冲突。
    这个时候就建议不使用using namespace std;

  • 相关阅读:
    使用哪些工具,可以提升 Python 项目质量?
    python字符串相关
    深耕5G,芯讯通持续推动5G应用百花齐放
    python实现ssl通信
    【linux实用命令】
    为爱出发,与善同行丨纬创软件2023北京善行者圆满收官
    vue 使用Html2Canvas对元素截图 下载
    软件测试基础——缺陷报告全教程,建议转发收藏
    数据库-MySQL-基础(6)- DCL
    iOS基础介绍(一)
  • 原文地址:https://blog.csdn.net/Phantom_matter/article/details/132734256