【发布时间】:2021-10-22 17:35:13
【问题描述】:
我今天开始在我的 Windows 操作系统中进行 C 编程,并完全按照 Visual Studio Code 网站(说明 - https://code.visualstudio.com/docs/cpp/config-mingw)中的描述下载并安装了 GCC 编译器。另外,我已经正确设置了环境变量。一切都在顺利进行。为了说明,我使用 MSYS2 安装了 GCC 编译器。正在使用mingw64。
操作系统 - Windows 10
二手-Mingw64版本
所以我自愿犯了一个错误来检查我的代码,并且该错误在终端中被打印了两次,这非常令人不安。编译并获取我正在使用的错误
gcc -Wall -ansi -pedantic -Werror testing.c -o out
我想摆脱在同一个问题上同时出现两个错误,而只得到一个错误。我们将不胜感激。
#include<stdio.h>
int main(void)
{
int s = 76;
printf("%f", s);
return 0;
}
如上所示的代码
Acer Aspire 5@LAPTOP-IDII92M3 MINGW64 ~/Desktop/New folder
$ gcc -Wall -ansi -pedantic -Werror testing.c -o out
testing.c: In function 'main':
testing.c:7:14: error: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Werror=format=]
7 | printf("%f", s);
| ~^ ~
| | |
| | int
| double
| %d
testing.c:7:14: error: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Werror=format=]
7 | printf("%f", s);
| ~^ ~
| | |
| | int
| double
| %d
cc1.exe: all warnings being treated as errors
如上所示,我两次收到完全相同的错误消息。我可以根据请求发送图片。
在注释中,我在我的 Linux 虚拟机中尝试了同样的错误。但是,当涉及到 Linux 时,编译器是不一样的,对吧?因此,在 Linux 系统中,我不会两次收到错误消息。我只得到一次错误,这是得到它的正确方法。
【问题讨论】:
-
为什么要担心这个?解决问题,您将不会得到任何。
-
关心编程工具的质量是完全理智的。编译器两次打印一条错误消息并不代表质量好。 - 也就是说,我无法重现该行为。
-
是的,我正在寻找解决问题的方法,但无法找到天气风向标 :)
-
完全同意你的阿玛利。我什至尝试了 CMD 命令行,但我得到了两次错误。我认为编译器有问题。我应该尝试从其他来源安装。
标签: c gcc compiler-errors system gcc-warning