gcc-Flag til valgmulighed

gcc -Wall aktiverer alle kompilators advarsler. Denne mulighed skal altid bruges for at generere bedre kode.

Syntaks

$ gcc -Wall [options] [source files] [object files] [-o output file]

Eksempel

Skriv kildefil myfile.c :

// myfile.c
#include <stdio.h/

int main()
{
    printf("Program run!\n");
    int i=10;
}

 

Regelmæssig build af myfile.c giver ingen beskeder:

$ gcc myfile.c -o myfile
$

 

Byg af myfile.c med -Wall :

$ gcc -Wall myfile.c -o myfile
myfile.c In function 'main':
myfile.c:6:6: warning: unused variable 'i'
myfile.c:7:1: warning: control reaches end of non-void function
$

 

 

 


Se også

GCC
HUKyLabsIGE TABLER