Search notes:

gcc -W

-Wdeprecated-declaration

With the option -Wdeprecated-declaration in effect, the compiler will warn about the use of deprecated variables, structs and functions.
These are declared as deprecated with __attribute__((deprecated)).

-Wfloat-equal

//
//      -Wfloat-equal:
//        Warn if two floating-point numbers are compared.
//
//  gcc -Wfloat-equal float-equal.c
//

#include <stdio.h>

int main() {

  float f1 = 4.2549342;
  float f2 = 4.2549343;

  if (f1 == f2) {
    printf("f1 == f2\n");
  }
}
Github repository about-gcc, path: /options/W/float-equal.c

-Winit-self

//
//   -Winit-self
//        Warn about variables that are initialized with themselves.
//        Option can only be used together with -Wuninitialized.
//
//   gcc -Wuninitialized -Winit-self init-self.c
//

#include <stdio.h>
int main() {

  int i = i;

  printf("i=%d\n", i);

}
Github repository about-gcc, path: /options/W/init-self.c

-Wshadow

//
//     -Wshadow:
//      Warn about local variables shadowing another variable.
//
// gcc -Wshadow shadow.c

#include <stdio.h>

int main() {

  int i = 42;

  if (i == 42) {

    printf("i=%d\n", i);
    int i = 49;
    printf("i=%d\n", i);

  }
}
Github repository about-gcc, path: /options/W/shadow.c

-Wundef

//
//   -Wundef:
//      Warn if an undefined macro is evaluated
//      in an #if construct.
//      

#include <stdio.h>


int main() {

#if UNDEFINED_MACRO > 5
  printf("UNDEFINED_MACRO is defined!!!\n");
#endif
  printf("Hello world\n");

}
Github repository about-gcc, path: /options/W/undef.c

-Wpedantic

-Wpedantic is equivalent to -pedantic.

-Wunreachable-code

//
//   -Wunreachable-code was supposed to warn if code was unreachable.
//    It functionality, not the warning, had been removed:
//
//      https://gcc.gnu.org/ml/gcc-help/2011-05/msg00360.html
//

#include <stdio.h>

void f() {
  printf("unreachable");
}

int main() {

  printf("1\n");
  return 0;
  printf("2\n");

}
Github repository about-gcc, path: /options/W/unreachable-code.c

See also

The cl options for warnings (/W…)
GCC options

Index