I started C programming today in my windows operating system and downloaded and installed the GCC compiler exactly as described in the Visual Studio Code Website (Instructions - https://code.visualstudio.com/docs/cpp/config-mingw). Also, I have set the environment variables correctly. Everything is running smooth. For the note, I installed the GCC compiler using MSYS2. The mingw64 is being used.
OS - Windows 10
Used - Mingw64 version
So I have willingly done an error to check my code and the error is being printed twice in the terminal and it's very disturbing. To compile and get the errors I'm using
gcc -Wall -ansi -pedantic -Werror testing.c -o out
I want to get rid of getting two errors at once for the same problem and just get one single error. Assitance will be appreciated.
#include<stdio.h>
int main(void)
{
int s = 76;
printf("%f", s);
return 0;
}
The above shown in the code
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
As shown above I get the same exact error message twice. I can send a picture under a request.
In a note I tried the same error in my Linux virtual machine. However, the compiler is not the same when it comes to Linux right? So, in the Linux system, I don't get the error twice. I just get the error only once which is the right way of getting it.