What Breaking Changes Are Introduced in C 11?
One of the significant changes introduced in C 11 is the explicit operator bool() in the standard library, replacing instances of operator void*(). While this change should address invalid code, there are other potential breaking changes to consider.
Core Language Incompatibilities
-
Modified String Literals Interpretation: Predefined macros like "u8" may modify string literals.
-
User-Defined String Literals: "_x" in string literals now creates user-defined string literals, instead of expanding macros.
-
New Keywords: Introduced keywords like "constexpr" and "thread_local" can break existing identifier names.
-
Integer Literal Modifications: Integer literals exceeding the range of "long" may now become "long long."
-
Integer Division Modifications: C 03 integer division rounding behavior may differ from C 11's rounding toward 0.
-
"auto" as Storage Specifier: C 03 code using "auto" as a storage specifier may become invalid.
-
Narrowing Conversions: C 03 narrowing conversions (e.g., double to int) may now be invalid.
-
Implicit Special Member Function Deletions: Ill-formed implicitly-defined member functions are automatically deleted.
-
Destructor Exception Specifications: User-declared destructors now have implicit noexcept(true) specifications.
-
"export" Declaration Elimination: C 03 declarations using "export" are now invalid.
-
Template Closing Modification: ">>" in templates may now close two templates instead of being considered only as a shift operator.
-
Dependent Calls of Internal Linkage Functions: Dependent calls of internal linkage functions are now allowed.
Library Modifications
-
Namespaced Identifiers: Identifiers added to the standard library may break existing code.
-
Header Includes: Headers previously located in certain standard headers (e.g., , ) may have moved elsewhere.
-
"posix" Namespace: The "posix" namespace is now reserved for future standardization.
-
Macro Definitions: Defining "override," "final," "carries_dependency," or "noreturn" as macros may now be invalid.
The above is the detailed content of What Breaking Changes Should I Be Aware of When Migrating to C 11?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn