Home >Backend Development >C++ >Why Was the 'static' Keyword Deprecated in C and Then Undeprecated?

Why Was the 'static' Keyword Deprecated in C and Then Undeprecated?

Linda Hamilton
Linda HamiltonOriginal
2024-11-16 12:10:03565browse

Why Was the 'static' Keyword Deprecated in C   and Then Undeprecated?

De-Deprecation of the 'static' Keyword in C

In C , the 'static' keyword could be used to control the visibility of symbols within a translation unit. However, in n3092, its usage within namespace scope was deprecated. This deprecation has since been removed in n3225.

The removal of the deprecation is explained in C Standard Core Language Defect Reports and Accepted Issues, Revision 94:

1012. Undeprecating static

Although 7.3.1.1 [namespace.unnamed] states that the use of the static keyword for declaring variables in namespace scope is deprecated because the unnamed namespace provides a superior alternative, it is unlikely that the feature will be removed at any point in the foreseeable future.

In essence, the deprecation was acknowledged to be nonsensical. 'static' will likely remain a part of C due to its utility in declaring functions and objects with internal linkage without the need for unnecessary boilerplate code in unnamed namespaces.

The above is the detailed content of Why Was the 'static' Keyword Deprecated in C and Then Undeprecated?. 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