summaryrefslogtreecommitdiff
path: root/devdocs/c/language%2Fattributes%2Fdeprecated.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/language%2Fattributes%2Fdeprecated.html')
-rw-r--r--devdocs/c/language%2Fattributes%2Fdeprecated.html65
1 files changed, 65 insertions, 0 deletions
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 @@
+ <h1 id="firstHeading" class="firstHeading">C attribute: deprecated <span class="t-mark-rev t-since-c23">(since C23)</span>
+</h1> <p>Indicates that the name or entity declared with this attribute is <a href="https://en.wikipedia.org/wiki/Deprecation" class="extiw" title="enwiki:Deprecation">deprecated</a>, that is, the use is allowed, but discouraged for some reason.</p>
+<h3 id="Syntax"> Syntax</h3> <table class="t-sdsc-begin"> <tr class="t-sdsc"> <td> <code>[[</code> <code>deprecated</code> <code>]]</code><br><code>[[</code> <code>__deprecated__</code> <code>]]</code> </td> <td> (1) </td> <td class="t-sdsc-nopad"> </td>
+</tr> <tr class="t-sdsc"> <td> <code>[[</code> <code>deprecated</code> <code>(</code> <span class="t-spar">string-literal</span> <code>)</code> <code>]]</code><br><code>[[</code> <code>__deprecated__</code> <code>(</code> <span class="t-spar">string-literal</span> <code>)</code> <code>]]</code> </td> <td> (2) </td> <td class="t-sdsc-nopad"> </td>
+</tr>
+</table> <table class="t-par-begin"> <tr class="t-par"> <td> <span class="t-spar">string-literal</span> </td> <td> - </td> <td> text that could be used to explain the rationale for deprecation and/or to suggest a replacing entity </td>
+</tr>
+</table> <h3 id="Explanation"> Explanation</h3> <p>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 <span class="t-spar">string-literal</span>, if specified, is usually included in the warnings.</p>
+<p>This attribute is allowed in declarations of the following names or entities:</p>
+<ul>
+<li> <a href="../struct" title="c/language/struct">struct</a>/<a href="../union" title="c/language/union">union</a>: <code>struct [[deprecated]] S;</code>, </li>
+<li> <a href="../typedef" title="c/language/typedef">typedef-name</a>: <code>[[deprecated]] typedef S* PS;</code>, </li>
+<li> objects: <code>[[deprecated]] int x;</code>, </li>
+<li> struct/union member: <code>union U { [[deprecated]] int n; };</code>, </li>
+<li> <a href="../function_definition" title="c/language/function definition">function</a>: <code>[[deprecated]] void f(void);</code>, </li>
+<li> <a href="../enum" title="c/language/enum">enumeration</a>: <code>enum [[deprecated]] E {};</code>, </li>
+<li> enumerator: <code>enum { A [[deprecated]], B [[deprecated]] = 42 };</code>. </li>
+</ul> <p>A name declared non-deprecated may be redeclared deprecated. A name declared deprecated cannot be un-deprecated by redeclaring it without this attribute.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+
+[[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();
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">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.</pre></div> </div> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/language/attributes/deprecated" title="cpp/language/attributes/deprecated">C++ documentation</a></span> for <code>deprecated</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/language/attributes/deprecated" class="_attribution-link">https://en.cppreference.com/w/c/language/attributes/deprecated</a>
+ </p>
+</div>