Der folgende Code kompiliert und ausgeführt Kompilieren aber ich erwarte eine Warnung beim Kompilieren:GCC emittieren keine Warnung, wenn
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 10;
printf("%p\n",&x);
return EXIT_SUCCESS;
}
GCC,from an online compiler mit Kommandozeilenargument
-Wall -std=gnu99 -O2 -o a.out source_file.c -pedantic -Wextra
die folgende Warnung ausgibt, wenn Kompilieren
source_file.c: In function ‘main’:
source_file.c:7:3: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=]
printf("%p\n",&x);
weil ich keine (void*)
hinzugefügt habe werfen, bevor &x
als %p
erwartet ein Argument vom Typ void*
.Aber wenn ich
gcc SO.c -o so -Wall -Wextra -pedantic -std=c11
oder
gcc SO.c -o so -Wall -Wextra -pedantic -std=c99
oder
gcc SO.c -o so -Wall -Wextra -pedantic -std=c89
GCC kompilieren (in meinem PC) tut nicht geben eine Warnung während kompilieren (wieder in meinem PC) mit
gcc SO.c -o so -Wall -Wextra -pedantic -std=gnu11
oder
gcc SO.c -o so -Wall -Wextra -pedantic -std=gnu99
oder
gcc SO.c -o so -Wall -Wextra -pedantic -std=gnu89
oder
gcc SO.c -o so -Wall -Wextra -pedantic
Ich erhalte die Warnung oben erwähnt. Warum ist es so? Meine GCC-Version ist 4.8.1 und ich verwende Windows. Ich kompiliere von der Konsole, d. H. cmd
.
Ist es mingw gcc, cygwin gcc oder etwas anderes? – ouah
@ouah, ich weiß es nicht genau, aber die Verwendung von 'gcc -v' zeigt' Target: mingw32'. Also nehme ich an, dass sein mingw gcc –