<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Static_variable</id>
	<title>Static variable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Static_variable"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Static_variable&amp;action=history"/>
	<updated>2026-05-05T00:39:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Static_variable&amp;diff=6172831&amp;oldid=prev</id>
		<title>24.50.56.74: /* Example */ Indentation of 4 spaces, and remove | characters</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Static_variable&amp;diff=6172831&amp;oldid=prev"/>
		<updated>2025-09-12T15:30:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Example: &lt;/span&gt; Indentation of 4 spaces, and remove | characters&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Previous revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:30, 12 September 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l43&quot;&gt;Line 43:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 43:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;void &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Func&lt;/del&gt;() {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;void &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;func&lt;/ins&gt;() {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  &lt;/del&gt;static int x = 0;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;static int x = 0;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  &lt;/del&gt;// &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|&lt;/del&gt;x&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;| &lt;/del&gt;is initialized only once across five calls of &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|Func| &lt;/del&gt;and the variable&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;// x is initialized only once across five calls of &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;func() &lt;/ins&gt;and the variable&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  &lt;/del&gt;// will get incremented five times after these calls. The final value of &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|&lt;/del&gt;x&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;// will get incremented five times after these calls. The final value of x&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  &lt;/del&gt;// will be 5.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;// will be 5.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  &lt;/del&gt;x++;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;x++;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  &lt;/del&gt;printf(&quot;%d\n&quot;, x);  // outputs the value of &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|&lt;/del&gt;x&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;printf(&quot;%d\n&quot;, x);  // outputs the value of x&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;int main() {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;int main() {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  Func&lt;/del&gt;(); &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;// prints 1&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    func&lt;/ins&gt;(); // prints 1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  Func&lt;/del&gt;(); &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;// prints 2&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    func&lt;/ins&gt;(); // prints 2&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  Func&lt;/del&gt;(); &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;// prints 3&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    func&lt;/ins&gt;(); // prints 3&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  Func&lt;/del&gt;(); &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;// prints 4&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    func&lt;/ins&gt;(); // prints 4&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  Func&lt;/del&gt;(); &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;// prints 5&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    func&lt;/ins&gt;(); // prints 5&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  &lt;/del&gt;return 0;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;return 0;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>24.50.56.74</name></author>
	</entry>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Static_variable&amp;diff=1156088&amp;oldid=prev</id>
		<title>imported&gt;GreenC bot: Rescued 1 archive link. Wayback Medic 2.5 per :Category:All articles with dead external links - pass 4</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Static_variable&amp;diff=1156088&amp;oldid=prev"/>
		<updated>2025-01-24T03:38:44Z</updated>

		<summary type="html">&lt;p&gt;Rescued 1 archive link. &lt;a href=&quot;/wiki143/index.php?title=User:GreenC/WaybackMedic_2.5&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:GreenC/WaybackMedic 2.5 (page does not exist)&quot;&gt;Wayback Medic 2.5&lt;/a&gt; per &lt;a href=&quot;/wiki143/index.php?title=Category:All_articles_with_dead_external_links&quot; title=&quot;Category:All articles with dead external links&quot;&gt;Category:All articles with dead external links&lt;/a&gt; - pass 4&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{short description|Programming variable that persists for the lifetime of the program}}&lt;br /&gt;
{{see also|Static (keyword)}}&lt;br /&gt;
In [[computer programming]], a &amp;#039;&amp;#039;&amp;#039;static variable&amp;#039;&amp;#039;&amp;#039; is a [[variable (programming)|variable]] that has been [[memory allocation|allocated]] &amp;quot;statically&amp;quot;, meaning that its [[variable lifetime|lifetime]] (or &amp;quot;extent&amp;quot;) is the entire run of the program. This is in contrast to shorter-lived [[automatic variable]]s, whose storage is [[stack allocation|stack allocated]] and deallocated on the [[call stack]]; and in contrast to [[dynamic memory allocation|dynamically allocated]] objects, whose storage is allocated and deallocated in [[heap memory]].&lt;br /&gt;
&lt;br /&gt;
[[Variable lifetime]] is contrasted with [[Scope (computer science)|scope]] (where a variable can be used): &amp;quot;global&amp;quot; and &amp;quot;local&amp;quot; refer to scope, not lifetime, but scope often implies lifetime. In many languages, [[global variable]]s are always static, but in some languages they are dynamic, while [[local variable]]s are generally automatic, but may be static.&lt;br /&gt;
&lt;br /&gt;
In general, &amp;#039;&amp;#039;&amp;#039;{{visible anchor|static memory allocation}}&amp;#039;&amp;#039;&amp;#039; is the allocation of memory at [[compile time]], before the associated program is executed, unlike [[dynamic memory allocation]] or [[automatic memory allocation]] where memory is allocated as required at [[run time (program lifecycle phase)|run time]].&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| access-date = 2011-06-16&lt;br /&gt;
| author = Jack Rons &lt;br /&gt;
| publisher = MeritHub [An Institute of Career Development]&lt;br /&gt;
| title = What is static memory allocation and dynamic memory allocation?&lt;br /&gt;
| quote = The compiler allocates required memory space for a declared variable. By using the addressof operator, the reserved address is obtained and this address may be assigned to a pointer variable. Since most of the declared variables have static memory, this way of assigning pointer value to a pointer variable is known as static memory allocation. Memory is assigned during compilation time.&lt;br /&gt;
| url = http://www.merithub.com/q/58-static-memory-allocation-dynamic-memory-allocation.aspx| archive-url = https://web.archive.org/web/20100611071852/http://www.merithub.com/q/58-static-memory-allocation-dynamic-memory-allocation.aspx| url-status = dead| archive-date = June 11, 2010}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
Static variables date at least to [[ALGOL 60]] (1960), where they are known as &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;own&amp;#039;&amp;#039;&amp;#039; variables&amp;#039;&amp;#039;:&lt;br /&gt;
{{quote&lt;br /&gt;
|A declaration may be marked with the additional declarator &amp;#039;&amp;#039;&amp;#039;own.&amp;#039;&amp;#039;&amp;#039; This has the following effect: upon a re-entry into the block, the values of &amp;#039;&amp;#039;&amp;#039;own&amp;#039;&amp;#039;&amp;#039; quantities will be unchanged from their values at the last exit, while the values of declared variables that are not marked with &amp;#039;&amp;#039;&amp;#039;own&amp;#039;&amp;#039;&amp;#039; is undefined.&lt;br /&gt;
|Revised report on ALGOL 60, section &amp;quot;5. Declarations&amp;quot;, p. 14}}&lt;br /&gt;
This definition is subtly different from a static variable: it only specifies behavior, and hence lifetime, not storage: an own variable can be allocated when a function is first called, for instance, rather than at program load time.&lt;br /&gt;
&lt;br /&gt;
The use of the word &amp;#039;&amp;#039;static&amp;#039;&amp;#039; to refer to these variables dates at least to [[BCPL]] (1966), and has been popularized by the [[C programming language]], which was heavily influenced by BCPL. The BCPL definition reads:&lt;br /&gt;
{{quote&lt;br /&gt;
|(1) Static data items:&amp;lt;br&amp;gt;Those data items whose extents lasts as long as the program execution time; such data items have manifest constant Lvalues. Every static data item must have been declared either in a function or routine definition, in a global declaration or as a label set by colon.&lt;br /&gt;
|The BCPL Reference Manual, 7.2 Space Allocation and Extent of Data Items}}&lt;br /&gt;
Note that BCPL defined a &amp;quot;dynamic data item&amp;quot; for what is now called an &amp;#039;&amp;#039;automatic&amp;#039;&amp;#039; variable (local, stack-allocated), not for heap-allocated objects, which is the current use of the term &amp;#039;&amp;#039;dynamic allocation&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The [[Static (keyword)|&amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt; keyword]] is used in C and related languages both for static variables and other concepts.&lt;br /&gt;
&lt;br /&gt;
==Addressing==&lt;br /&gt;
{{Unreferenced section|date=June 2023}}&lt;br /&gt;
The [[absolute address]] [[addressing mode]] can only be used with static variables, because those are the only kinds of variables whose location is known by the compiler at compile time. When the program ([[executable]] or [[Library (computing)|library]]) is [[Loader (computing)|loaded]] into memory, static variables are stored in the [[data segment]] of the program&amp;#039;s [[Address space (application programming)|address space]] (if initialized), or the [[BSS segment]] (if uninitialized), and are stored in corresponding sections of [[object file]]s prior to loading.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
{{Unreferenced section|date=June 2023}}&lt;br /&gt;
{{see also|Variable (computer science)#Scope and extent}}&lt;br /&gt;
&lt;br /&gt;
In terms of [[Variable (computer science)#Scope and extent|scope and extent]], static variables have extent the entire run of the program, but may have more limited [[Scope (computer science)|scope]]. A basic distinction is between a &amp;#039;&amp;#039;static global variable&amp;#039;&amp;#039;, which has global scope and thus is in context throughout the program, and a &amp;#039;&amp;#039;[[static local variable]],&amp;#039;&amp;#039; which has local scope. A static local variable is different from a local variable as a static local variable is initialized only once no matter how many times the function in which it resides is called and its value is retained and accessible through many calls to the function in which it is declared, e.g. to be used as a count variable. A static variable may also have [[module scope]] or some variant, such as [[internal linkage]] in [[C programming language|C]], which is a form of file scope or module scope.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
An example of a static local variable in C:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void Func() {&lt;br /&gt;
  static int x = 0;&lt;br /&gt;
  // |x| is initialized only once across five calls of |Func| and the variable&lt;br /&gt;
  // will get incremented five times after these calls. The final value of |x|&lt;br /&gt;
  // will be 5.&lt;br /&gt;
  x++;&lt;br /&gt;
  printf(&amp;quot;%d\n&amp;quot;, x);  // outputs the value of |x|&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  Func();  // prints 1&lt;br /&gt;
  Func();  // prints 2&lt;br /&gt;
  Func();  // prints 3&lt;br /&gt;
  Func();  // prints 4&lt;br /&gt;
  Func();  // prints 5&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Object-oriented programming ==&lt;br /&gt;
{{Unreferenced section|date=June 2023}}&lt;br /&gt;
In [[object-oriented programming]], there is also the concept of a &amp;#039;&amp;#039;[[static member variable]]&amp;#039;&amp;#039;, which is a &amp;quot;[[class variable]]&amp;quot; of a statically defined class, i.e., a [[member variable]] of a given class which is shared across all [[class instance|instances]] (objects), and is accessible as a member variable of these objects. A class variable of a dynamically defined class, in languages where classes can be defined at run time, is allocated when the class is defined and is not static.&lt;br /&gt;
&lt;br /&gt;
Object constants known at compile-time, such as [[string literal]]s, are usually allocated statically. In object-oriented programming, the [[virtual method table]]s of classes are usually allocated statically. A statically defined value can also be [[Global variable|global]] in its scope ensuring the same [[Immutable object|immutable]] value is used throughout a run for consistency.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Constant (computer programming)]]&lt;br /&gt;
* [[Global variable]]&lt;br /&gt;
* [[Static method]]&lt;br /&gt;
* [[Thread-local storage]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
{{Reflist|2}}&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{refbegin}}&lt;br /&gt;
* {{cite book |title=The C Programming Language |last1=Kernighan |first1=Brian W. |author-link1=Brian Kernighan |last2=Ritchie |first2=Dennis M. |author-link2=Dennis Ritchie |year=1988 |publisher=Prentice Hall PTR |place=Upper Saddle River, NJ |edition=2nd |isbn=0-13-110362-8 |url-access=registration |url=https://archive.org/details/cprogramminglang00bria }}&lt;br /&gt;
*&amp;#039;&amp;#039;[[The C++ Programming Language]]&amp;#039;&amp;#039; (special edition) by [[Bjarne Stroustrup]] (Addison Wesley, 2000; {{ISBN|0-201-70073-5}})&lt;br /&gt;
{{refend}}&lt;br /&gt;
&lt;br /&gt;
{{Memory management navbox}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--Categories--&amp;gt;&lt;br /&gt;
{{DEFAULTSORT:Static Memory Allocation}}&lt;br /&gt;
[[Category:Memory management]]&lt;br /&gt;
[[Category:Variable (computer science)]]&lt;/div&gt;</summary>
		<author><name>imported&gt;GreenC bot</name></author>
	</entry>
</feed>