Also controls -Wdocumentation-unknown-command. Also controls -Wformat-extra-args, -Wformat-insufficient-args, -Wformat-invalid-specifier, -Wformat-security, -Wformat-y2k, -Wformat-zero-length, -Wnonnull. bytes) pass-by-value object; pass it by reference instead ? Warnings only with Clang, not GCC nor MSVC, but the very many warning are cluttering the log files. Literally every warning in clang. : conditional expression extension, omitting middle operand, use of GNU ‘missing =’ extension in designator, use of GNU old-style field designator extension, flexible array initialization is a GNU extension, constant expression; folding it to a constant is a GNU extension, in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension, variable length array folded to constant array as an extension, ‘gnu_inline’ attribute without ‘extern’ in C++ treated as externally available, this changed in Clang 10, use of GNU statement expression extension, in-class initializer for static data member of type, string literal operator templates are a GNU extension, not at the end of a struct or class is a GNU extension, #line directive with zero argument is a GNU extension, must specify at least one argument for ‘…’ parameter of variadic macro, token pasting of ‘,’ and __VA_ARGS__ is a GNU extension, is used as a header guard here, followed by #define of a different macro, using namespace directive in global context in header, ’ is ignored since it is only supported for HIP, using the result of an assignment as a condition without parentheses, ‘cmse_nonsecure_entry’ cannot be applied to functions with internal linkage, ‘dllexport’ attribute ignored on explicit instantiation definition, has no effect when annotating an ‘if constexpr’ statement, has no effect when annotating an infinite loop, attribute can only be applied to instance variables or properties, attribute ignored on a non-definition declaration, ’ attribute cannot be specified on a definition, ignored, because it is not attached to a declaration, ‘nonnull’ attribute applied to function with no pointer arguments, ‘nonnull’ attribute when used on parameters takes no arguments, attribute only applies to a pointer or reference (, attribute declaration must precede definition, attribute only applies to return values that are pointers, attribute only applies to return values that are pointers or references, ‘sentinel’ attribute requires named arguments, ‘sentinel’ attribute only supported for variadic, __weak attribute cannot be specified on a field declaration, __weak attribute cannot be specified on an automatic variable when ARC is not enabled, ignored, because it cannot be applied to omitted return type, ignored, because it cannot be applied to a type, ignoring __declspec(allocator) because the function return type, ‘deprecated’ attribute on anonymous namespace ignored, is already applied with different arguments, Objective-C GC does not allow weak variables on the stack, ‘gnu_inline’ attribute requires function to be marked ‘inline’, attribute ignored, ‘objc_externally_retained’ can only be applied to local variables, cannot be applied to a function with a definition, ‘internal_linkage’ attribute on a non-static local variable is ignored, ‘interrupt’ attribute only applies to functions that have, qualifiers after comma in declarator list are ignored, ‘mig_server_routine’ attribute only applies to routines that return a kern_return_t, ‘nocf_check’ attribute ignored; use -fcf-protection to enable the attribute, ‘noderef’ can only be used on an array or pointer type, attribute is ignored because there exists no call expression inside the statement, ‘nothrow’ attribute conflicts with exception specification; attribute ignored, attribute isn’t implemented by this Objective-C runtime, ignored (not implemented by this Objective-C runtime), attribute is deprecated and ignored in OpenCL version, ‘require_constant_initialization’ attribute added after initialization of variable, template parameter of a function template with the ‘sycl_kernel’ attribute cannot be a non-type template parameter, function template with ‘sycl_kernel’ attribute must have a single parameter, ‘sycl_kernel’ attribute only applies to a function template with at least two template parameters, function template with ‘sycl_kernel’ attribute must have a ‘void’ return type, of the first field in transparent union; transparent_union attribute ignored, first field of a transparent union cannot have, transparent_union attribute can only be applied to a union definition; attribute ignored, transparent union definition must contain at least one field; transparent_union attribute ignored, ’ in the ‘target’ attribute string; ‘target’ attribute ignored. implicit conversion increases floating-point precision: ISO C++ considers this destructor name lookup to be ambiguous, ISO C++ requires the name after ‘::~’ to be found in the same scope as the name before ‘::~’, qualified destructor name only found in lexical scope; omit the qualifier to find this type name by unqualified lookup, multiple identical address spaces specified for type, ISO C++17 does not allow dynamic exception specifications, non-defining declaration of enumeration with a fixed underlying type is only permitted as a standalone declaration, reference to enumeration must use ‘enum’ not ‘enum, embedding a directive within macro arguments has undefined behavior, ISO C++17 does not allow a decomposition group to be empty, ISO C requires a translation unit to contain at least one declaration, comparison of different enumeration types in switch statement, implicit conversion from enumeration type, enumeration values exceed range of largest integer, is not representable in the largest integer type, cannot refer to a non-static member from the handler of a, has a non-throwing exception specification but can still throw, excess elements in initializer for indivisible sizeless type, excess elements in char array initializer, initializer-string for char array is too long, declaration requires an exit-time destructor, macro expansion producing ‘defined’ has undefined behavior, explicit call to +initialize results in duplicate call to +initialize, explicit call to [super initialize] should only be in implementation of +initialize, ISO C++20 does not permit a declaration that does not introduce any names to be exported, ISO C++20 does not permit using directive to be exported, call to function without interrupt attribute could clobber interruptee’s VFP registers, extra ‘;’ after member function definition, empty expression statement has no effect; remove unnecessary ‘;’ to silence this warning, enumeration types with a fixed underlying type are a Clang extension, is out of range of flags in enumeration type, may not be used as an array element due to flexible array member, may not be nested in a struct due to flexible array member. This is particularly useful when writing a header file that will be compiled by other people, because you don't know what warning flags they build with. To discover the Clang diagnostics benefits, let’s compile a minimal C++ source code with both Visual C++ and Clang, and compare between the warnings reported. Clang documentation provides reference for some of the diagnostic flags in Clang. Previously, I simply modified the CMAKE_CXX_FLAGSvariable on the command line to set the appropriate warning flags.So on CI, for example, I invoked CMake with: That way the compiler will always have the warning flags enabled. Without it, for example: a * intended for pointer declaration will actually be interpreted as multiplication; and unless the intended variable already happens to be in scope, this error will occur, trying to multiply the template-value with the undeclared identifier ('var' in this example). Read on to learn about further configuration options. Due to two-phase name lookup in templates, identifiers found in base classes are not resolved unless qualified with this->. This diagnostic is an error by default, but the flag -Wno-module-file-config-mismatch can be used to disable the error. Also controls -Warc-maybe-repeated-use-of-weak. Warnings may be enabled or suppressed individually, which requires the name of the warning. Controls -Wc++17-compat-mangling, -Wc++98-c++11-c++14-c++17-compat, -Wdeprecated-increment-bool, -Wdeprecated-register. Also controls -Wtautological-bitwise-compare, -Wtautological-constant-compare, -Wtautological-objc-bool-compare, -Wtautological-overlap-compare, -Wtautological-pointer-compare, -Wtautological-undefined-compare. Also controls -Wdeprecated-dynamic-exception-spec. Also controls -Wc++11-extra-semi, -Wc++11-inline-namespace, -Wc++11-long-long. Received warning after diagnostic serialization teardown was underway: unable to merge a subprocess’s serialized diagnostics, shifting a negative signed value is undefined, ) sets the sign bit of the shift expression’s type (. -Wno-missing-profile can be used to disable the warning, but this is not recommended and should be done only when non-existent profile data is justified. is required to declare the member ‘unhandled_exception()’ when exceptions are enabled, default label in switch which covers all enumeration values, which is being passed as a formatting argument to the formatting, may not intend to support class template argument deduction. in order to get capability with existing async C API. “-Wundef”), the number of preprocessor source tokens (, the total number of preprocessor source tokens (. Also controls -Wdeprecated-objc-pointer-introspection-performSelector. This diagnostic is an error by default, but the flag -Wno-invalid-ios-deployment-target can be used to disable the error. Clang: Manually Disable Warnings in a Specific Location Utilizing public or generated code can often introduce warnings into your software builds. Static data members should be declared in a header, and defined only once in a source file (not the header). Clang-Tidy configuration. clang internal diagnostic codes (e.g. Also controls -Wvoid-pointer-to-enum-cast. clangd runs the clang compiler on your code as you type, and shows errors and warnings in-place. While C++11 is now several years old already, there’s still lots of code bases which don’t use any of the new language features, be it by policy from management, or by pure laziness to avoid the porting effort from the developer side. ’ requires the declaration of the ‘jmp_buf’ type, commonly provided in the header . Controls -Wincomplete-umbrella, -Wnon-modular-include-in-module. Code ported from BCC32 may exhibit some of these warnings (listed alphabetically), which may be suppressed. ; allow reordering by specifying ‘#pragma clang loop vectorize(enable)’ before the loop. conflicting nullability specifier on parameter types. Also controls -Wobjc-signed-char-bool-implicit-int-conversion. Clang-Tidy from the LLVM compiler inf… Also controls -Wfloat-overflow-conversion, -Wfloat-zero-conversion. Make the pointer const (and if appropriate, consider using std::string). Also controls -Wdeprecated-writable-strings. Controls -Warc-non-pod-memaccess, -Warc-retain-cycles, -Warc-unsafe-retained-assign. Controls -Wgnu-alignof-expression, -Wgnu-anonymous-struct, -Wgnu-auto-type, -Wgnu-binary-literal, -Wgnu-case-range, -Wgnu-complex-integer, -Wgnu-compound-literal-initializer, -Wgnu-conditional-omitted-operand, -Wgnu-designator, -Wgnu-empty-initializer, -Wgnu-empty-struct, -Wgnu-flexible-array-initializer, -Wgnu-flexible-array-union-member, -Wgnu-folding-constant, -Wgnu-imaginary-constant, -Wgnu-include-next, -Wgnu-label-as-value, -Wgnu-redeclared-enum, -Wgnu-statement-expression, -Wgnu-static-float-init, -Wgnu-string-literal-operator-template, -Wgnu-union-cast, -Wgnu-variable-sized-type-not-at-end, -Wgnu-zero-line-directive, -Wgnu-zero-variadic-macro-arguments, -Wredeclared-class-member, -Wvla-extension, -Wzero-length-array. Use ‘–ld-path=’ instead, __final is a GNU extension, consider using C++11 final, attribute in this position on a function definition, ‘break’ is bound to loop, GCC binds it to switch, GCC does not allow the ‘cleanup’ attribute argument to be anything other than a simple identifier, GCC does not allow an attribute in this position on a function declaration, GCC does not allow variable declarations in for loop initializers before C99, ’ is bound to current loop, GCC binds it to the enclosing loop, declaration requires a global constructor, -fglobal-isel support is incomplete for this architecture at the current optimization level, applied to an expression is a GNU extension, parenthesized initialization of a member array is a GNU extension, binary integer literals are a GNU extension, complex integer types are a GNU extension, use of GNU ? Synonym for -Wc++11-compat-deprecated-writable-strings. This diagnostic is an error by default, but the flag -Wno-dtor-typedef can be used to disable the error. To treat warnings as errors, right click on your project name in the Solution Explorer window, then choose Properties: From the Project dialog, first make sure the Configuration field is set to All Configurations. All warnings will be enabled for the two compilers. Clang warning flags Clang includes -Weverything flag, that is not shown in these lists, that enables all warnings. Controls -Wshadow, -Wshadow-field, -Wshadow-field-in-constructor, -Wshadow-uncaptured-local. Controls -Wthread-safety-analysis, -Wthread-safety-attributes, -Wthread-safety-precise, -Wthread-safety-reference. Also controls -Wunreachable-code-loop-increment. already conforms to the protocols listed; did you forget a ‘*’? Also controls -Wignored-pragmas, -Wpragma-clang-attribute, -Wpragma-pack, -Wunknown-pragmas. Also controls -Wimplicit-int-float-conversion, -Wobjc-signed-char-bool-implicit-float-conversion.