2009-08-15 5 views

Antwort

7

Es kommt nur darauf an, wie Sie gcc aufrufen:

 
/tmp/c$ gcc -Wall bad.c 
bad.c:1: warning: return type defaults to ‘int’ 
bad.c: In function ‘main’: 
bad.c:1: warning: control reaches end of non-void function 

vs

 
/tmp/c$ gcc -Wall /tmp/c/bad.c 
/tmp/c/bad.c:1: warning: return type defaults to ‘int’ 
/tmp/c/bad.c: In function ‘main’: 
/tmp/c/bad.c:1: warning: control reaches end of non-void function 

vs

 
/tmp/c$ gcc -Wall ../../tmp/c/bad.c 
../../tmp/c/bad.c:1: warning: return type defaults to ‘int’ 
../../tmp/c/bad.c: In function ‘main’: 
../../tmp/c/bad.c:1: warning: control reaches end of non-void function 

wo Inhalte bad.c sind nur

main() { } 

wenn jemand interessiert.

+2

Es stimmt, das funktioniert, aber was ist, wenn es bereits ein kompliziertes Build-System einrichten? Es wäre schön, wenn ich CFLAGS etwas hinzufügen könnte, um die Ausgabe zu verbessern. –

2

Manchmal verwende ich ein sed-Skript dafür (z. B. wenn cmake verwendet wird, das immer volle Pfade verwendet). Dies kann auch nützlich sein, um andere Teile des Protokolls zu bereinigen, z. Vorlagennamen in C++.

-6

gcc 2>/dev/null :-) Auf einem echten Betriebssystem.

Verwandte Themen