From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/language%2Fattributes%2Fdeprecated.html | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 devdocs/c/language%2Fattributes%2Fdeprecated.html (limited to 'devdocs/c/language%2Fattributes%2Fdeprecated.html') diff --git a/devdocs/c/language%2Fattributes%2Fdeprecated.html b/devdocs/c/language%2Fattributes%2Fdeprecated.html new file mode 100644 index 00000000..d53195d3 --- /dev/null +++ b/devdocs/c/language%2Fattributes%2Fdeprecated.html @@ -0,0 +1,65 @@ +

C attribute: deprecated (since C23) +

Indicates that the name or entity declared with this attribute is deprecated, that is, the use is allowed, but discouraged for some reason.

+

Syntax

+ + +
[[ deprecated ]]
[[ __deprecated__ ]]
(1)
[[ deprecated ( string-literal ) ]]
[[ __deprecated__ ( string-literal ) ]]
(2)
+ +
string-literal - text that could be used to explain the rationale for deprecation and/or to suggest a replacing entity

Explanation

Indicates that the use of the name or entity declared with this attribute is allowed, but discouraged for some reason. Compilers typically issue warnings on such uses. The string-literal, if specified, is usually included in the warnings.

+

This attribute is allowed in declarations of the following names or entities:

+

A name declared non-deprecated may be redeclared deprecated. A name declared deprecated cannot be un-deprecated by redeclaring it without this attribute.

+

Example

#include <stdio.h>
+ 
+[[deprecated]]
+void TriassicPeriod(void)
+{
+    puts("Triassic Period: [251.9 - 208.5] million years ago.");
+}
+ 
+[[deprecated("Use NeogenePeriod() instead.")]]
+void JurassicPeriod(void)
+{
+    puts("Jurassic Period: [201.3 - 152.1] million years ago.");
+}
+ 
+[[deprecated("Use calcSomethingDifferently(int).")]]
+int calcSomething(int x)
+{
+    return x * 2;
+}
+ 
+int main(void)
+{
+    TriassicPeriod();
+    JurassicPeriod();
+}

Possible output:

+
Triassic Period: [251.9 - 208.5] million years ago.
+Jurassic Period: [201.3 - 152.1] million years ago.
+ 
+prog.c:23:5: warning: 'TriassicPeriod' is deprecated [-Wdeprecated-declarations]
+    TriassicPeriod();
+    ^
+prog.c:3:3: note: 'TriassicPeriod' has been explicitly marked deprecated here
+[[deprecated]]
+  ^
+prog.c:24:5: warning: 'JurassicPeriod' is deprecated: Use NeogenePeriod() instead. [-Wdeprecated-declarations]
+    JurassicPeriod();
+    ^
+prog.c:9:3: note: 'JurassicPeriod' has been explicitly marked deprecated here
+[[deprecated("Use NeogenePeriod() instead.")]]
+  ^
+2 warnings generated.

See also

+
C++ documentation for deprecated
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/language/attributes/deprecated +

+
-- cgit v1.2.3