summaryrefslogtreecommitdiff
path: root/devdocs/c/language%2Ffile_scope.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/language%2Ffile_scope.html
new repository
Diffstat (limited to 'devdocs/c/language%2Ffile_scope.html')
-rw-r--r--devdocs/c/language%2Ffile_scope.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/devdocs/c/language%2Ffile_scope.html b/devdocs/c/language%2Ffile_scope.html
new file mode 100644
index 00000000..1e49b1cf
--- /dev/null
+++ b/devdocs/c/language%2Ffile_scope.html
@@ -0,0 +1,27 @@
+ <h1 id="firstHeading" class="firstHeading">File scope</h1> <p>If the declarator or type specifier that declares the identifier appears outside of any block or list of parameters, the identifier has file scope, which terminates at the end of the translation unit.</p>
+<p>So, placement of an identifier's declaration (in a declarator or type specifier) outside any block or list of parameters means that the identifier has file scope. File scope of an identifier extends from the declaration to the end of the translation unit in which the declaration appears.</p>
+<h3 id="Example"> Example</h3> <div class="t-example">
+<p>Identifiers a, b, f, and g have file scope.</p>
+<div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+
+int a = 1;
+static int b = 2;
+
+void f (void) {printf("from function f()\n");}
+static void g (void) {printf("from function g()\n");}
+
+int main(void)
+{
+ f();
+ g();
+
+ return 0;
+}
+/* end of this translation unit, end of file scope */</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">from function f()
+from function g()</pre></div> </div> <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/file_scope" class="_attribution-link">https://en.cppreference.com/w/c/language/file_scope</a>
+ </p>
+</div>