2401_82908200 2024-08-18 21:17 采纳率: 33.3%
浏览 4

cobol编译问题mingw报错

cobol编译问题
使用cobc -x编译Cobol文件时报错

In file included from D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/stddef.h:7,
                 from D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/stddef.h:1,     
                 from D:\GC312\include/stdio.h:69,
                 from C:\Users\ADMINI~1\AppData\Local\Temp\cob15496_0.c:8:
D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/crtdefs.h:35:18: error: expected ';' before 'typede 
'
 __MINGW_EXTENSION typedef unsigned __int64 size_t;
                  ^~~~~~~~
                  ;
D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/crtdefs.h:45:18: error: expected ';' before 'typede 
'
 __MINGW_EXTENSION typedef __int64 ssize_t;
                  ^~~~~~~~
                  ;
D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/crtdefs.h:62:18: error: expected ';' before 'typede 
'
 __MINGW_EXTENSION typedef __int64 intptr_t;
                  ^~~~~~~~
                  ;
D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/crtdefs.h:75:18: error: expected ';' before 'typede 
'
 __MINGW_EXTENSION typedef unsigned __int64 uintptr_t;
                  ^~~~~~~~
                  ;
D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/crtdefs.h:88:18: error: expected ';' before 'typede 
'
 __MINGW_EXTENSION typedef __int64 ptrdiff_t;
                  ^~~~~~~~
                  ;
D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/crtdefs.h:123:18: error: expected ';' before 'typedef'
 __MINGW_EXTENSION typedef __int64 __time64_t;
                  ^~~~~~~~
                  ;
In file included from D:\GC312\include/stdio.h:94,
                 from C:\Users\ADMINI~1\AppData\Local\Temp\cob15496_0.c:8:
D:\GC312\include/sys/types.h:123:21: error: conflicting types for 'ssize_t'
   typedef _ssize_t  ssize_t;
                     ^~~~~~~
In file included from D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/stddef.h:7,
                 from D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/stddef.h:1,
                 from D:\GC312\include/stdio.h:69,
                 from C:\Users\ADMINI~1\AppData\Local\Temp\cob15496_0.c:8:
D:/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/crtdefs.h:45:35: note: previous declaration of 'ssize_t' was here 
 __MINGW_EXTENSION typedef __int64 ssize_t;

但c++和c编译是正常的,请问怎么解决

  • 写回答

2条回答 默认 最新

  • 何事_ 2024-08-18 21:18
    关注

    以下回复参考:皆我百晓生券券喵儿等免费微信小程序作答:

    这个问题涉及到几个方面:Cobol 编译器错误、VSCode 中的问题以及 C/C++ 的兼容性。这里我将提供一个详细的解决方案。

    首先,我们来看看 Cobol 编译器错误。在您的环境中,您可能遇到了以下错误:

    1. 错误 35:在 stddef.h 文件中的 __MINGW_EXTENSION 定义。
    2. 错误 45:在 stdio.h 文件中的 __MINGW_EXTENSION 定义。
    3. 错误 62:在 crtdefs.h 文件中的 __MINGW_EXTENSION 定义。
    4. 错误 75:在 crtdefs.h 文件中的 __MINGW_EXTENSION 定义。
    5. 错误 88:在 crtdefs.h 文件中的 __MINGW_EXTENSION 定义。
    6. 错误 123:在 sys/types.h 文件中的 __MINGW_EXTENSION 定义。

    要解决这些问题,您可以尝试以下步骤:

    步骤 1:检查并更新环境变量

    确保您的系统上安装了正确的编译工具链(例如 GCC)。如果您正在使用 Windows 系统,建议查看 mingw64 链接文件,并确保所有必要的库都被正确添加到路径中。

    步骤 2:编辑相关头文件

    找到这些错误是在哪些文件中定义的,并且相应地修改它们。例如,在 stddef.hstdio.h 文件中删除不必要的 __MINGW_EXTENSION 定义,然后重新编译这些文件。这一步通常不需要更改其他文件,因为错误只出现在标准头文件中。

    步骤 3:检查 main.cmain.cpp 文件

    main.cmain.cpp 文件中,确认没有引入任何与错误相关的宏或函数。

    步骤 4:更新 VSCode 设置

    在 VSCode 中设置环境变量,使其能够识别和处理错误信息。打开 .vscode/settings.json 文件,添加以下内容:

    {
        "files.associations": {
            "*.cobl": "bin/cobol"
        }
    }
    

    步骤 5:测试修复后的项目

    保存所有的更改后,重新构建项目。如果一切正常,那么错误应该已经被解决了。

    步骤 6:验证和报告

    为了确保问题已得到解决,您可以再次运行项目并在 Visual Studio Code 中检查输出。如果仍然遇到问题,可以尝试查找更多关于错误的信息,或者联系 Cobol 编程社区寻求帮助。

    通过遵循上述步骤,你应该能成功解决这些 Cobol 编译错误。如果有任何疑问或需要进一步的帮助,请随时告诉我。

    评论

报告相同问题?

问题事件

  • 创建了问题 8月18日

悬赏问题

  • ¥15 封装的 matplotlib animation 不显示图像
  • ¥15 python摄像头画面无法显示
  • ¥15 关于#3d#的问题:d标定算法(语言-python)
  • ¥15 cve,cnnvd漏洞扫描工具推荐
  • ¥15 图像超分real-esrgan网络自己训练模型遇到问题
  • ¥15 如何构建全国统一的物流管理平台?
  • ¥100 ijkplayer使用AndroidStudio/CMake编译,如何支持 rtsp 直播流?
  • ¥15 用js遍历数据并对非空元素添加css样式
  • ¥15 使用autodl云训练,希望有直接运行的代码(关键词-数据集)
  • ¥50 python写segy数据出错