cờ tùy chọn gcc -Wall

gcc -Wall cho phép tất cả các thông báo cảnh báo của trình biên dịch.Tùy chọn này phải luôn được sử dụng để tạo mã tốt hơn.

cú pháp

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

Ví dụ

Ghi tệp nguồn myfile.c :

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

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

 

Bản dựng thông thường của myfile.c không đưa ra thông báo nào:

$ gcc myfile.c -o myfile
$

 

Bản dựng của myfile.c với -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
$

 

 

 


Xem thêm

Advertising

GCC
°• CmtoInchesConvert.com •°