Search code examples
cclang

What does `-Wextra` flag mean in clang compiler?


What is the meaning of -Wextra in clang compiler flag?

I was curious what does all the flags such as -Wall, -Werror means. I was able to find answers for others, but not -Wextra.

clang -Wall -Wextra -Werror

Solution

  • -Wextra flag is not specific to just the clang compiler, it is documented in the GCC Compiler as well. Basically, -Wall enables all (common) warning flags but this excludes many flags.

    Some of these, notably -Wempty-init-stmt, -Wignored-qualifiers, -Winitializer-overrides, -Wmissing-field-initializers, -Wmissing-method-return-type, -Wnull-pointer-arithmetic, -Wsemicolon-before-method-body, -Wsign-compare, -Wunused-parameter are covered by -Wextra instead.

    You can find out more about what each of these mean in the documentation.