Clang Flag: -Wc++14-extensions / -Wno-c++14-extensions

From emmtrix Wiki
Jump to navigation Jump to search
The Clang compiler flags -Wc++14-extensions and -Wno-c++14-extensions are used to control warnings related to C++14 language extensions. When compiling C++ code, developers might encounter language features that are specific to C++14. These flags offer a mechanism to either enable or suppress warnings for these features, aiding developers in maintaining compatibility with the C++14 standard.

The -Wc++14-extensions flag, when explicitly enabled, activates warnings for certain C++14 extensions that are not activated by default. This flag is useful for developers who aim to write portable code that adheres strictly to the C++14 standard without utilizing certain extensions that Clang allows by default. Currently, this includes features like binary integer literals and the use of certain C++14-specific attributes.

Conversely, the -Wno-c++14-extensions flag deactivates warnings for a broader range of C++14 extensions that are activated by default. This is beneficial for developers who are leveraging C++14 extensions knowingly and wish to suppress related warnings to focus on more relevant issues within their codebase. The default active warnings encompass features such as multiple return statements in constexpr functions, variable templates, and initialized lambda captures among others. By deactivating these warnings, developers can write code that takes full advantage of C++14 extensions without being encumbered by compiler warnings for doing so.

Both flags serve distinct purposes with -Wc++14-extensions being geared towards enforcing strict adherence to the C++14 standard by highlighting extensions, while -Wno-c++14-extensions allows developers the freedom to use C++14 specific features without compiler interference. These flags are part of the broader ecosystem of compiler options that assist in writing, debugging, and optimizing C++ code.

 
AI Generated

Supergroups

Subroups

Warnings/Remarks

Default Active (Deactivate with -Wno-c++14-extensions)

ext_constexpr_body_invalid_stmt
warning: use of this statement in a constexpr
function
constructor
is a C++14 extension

ext_constexpr_body_multiple_return warning: multiple return statements in constexpr function is a C++14 extension
ext_constexpr_local_var
warning: variable declaration in a constexpr
function
constructor
is a C++14 extension

ext_constexpr_type_definition
warning: type definition in a constexpr
function
constructor
is a C++14 extension

ext_decltype_auto_type_specifier warning: 'decltype(auto)' type specifier is a C++14 extension
ext_init_capture warning: initialized lambda captures are a C++14 extension
ext_variable_template warning: variable templates are a C++14 extension

Default Inactive (Activate with -Wc++14-extensions)

ext_binary_literal_cxx14 warning: binary integer literals are a C++14 extension
ext_cxx14_attr warning: use of the A attribute is a C++14 extension