Generally, a considerable amount of warning information is generated during code compilation, especially when the-wall option is used. -Wall does not open all warnings as it literally means. however, it has opened a lot of warnings. we can certainly block warnings that we know are "harmless" but still print out to occupy poor console space.
Take the following code for example:
#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <unistd.h>int main(void){long double ld = 10000.2222L;puts("hello world!???(y/n)");printf("long double type size is %lu %lu\n",sizeof(long double),sizeof ld);return 0;}
It generates a warning for the so-called "three character group symbol". If this is exactly what we need, we can ignore this warning. let's compile it to see first (whether using GCC or clang ):
GCC:
[email protected]:~/src/c_src$ gcc -Wall -std=c11 -O3 -g0 -s -o x x.cx.c: In function ‘main’:x.c:9:21: warning: trigraph ??( converted to [ [-Wtrigraphs] puts("hello world!???(y/n)"); ^
Clang:
[email protected]:~/src/c_src$ clang -Wall -std=c11 -O3 -g0 -s -o x x.cx.c:9:21: warning: trigraph converted to '[' character [-Wtrigraphs] puts("hello world!???(y/n)"); ^1 warning generated.
However, after removing the-Wall warning, you can find that there is no warning and everything is quiet. however, this is not what we want, because some warnings that truly imply error classes may be missed. you can see that the warning type is-wtrigraphs. we only need to add no after W to block this warning, but we need to put it behind the wall option. If we put it above, there will still be a warning. the compiler should be based on the last "valid" option!
[email protected]:~/src/c_src$ gcc -Wall -Wno-trigraphs -std=c11 -O3 -g0 -s -o x x.c
Methods for removing specific warnings in GCC or clang