{"id":11806,"date":"2026-08-07T14:47:51","date_gmt":"2026-08-07T05:47:51","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11806"},"modified":"2026-08-07T14:47:51","modified_gmt":"2026-08-07T05:47:51","slug":"c-c-static-%ed%82%a4%ec%9b%8c%eb%93%9c-%ec%99%84%eb%b2%bd-%ec%a0%95%eb%a6%ac-%eb%82%b4%eb%b6%80-static-vs-%ec%99%b8%eb%b6%80-static","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11806","title":{"rendered":"C\/C++ static \ud0a4\uc6cc\ub4dc \uc644\ubcbd \uc815\ub9ac: \ub0b4\ubd80 static vs \uc678\ubd80 static"},"content":{"rendered":"<h1>C\/C++ static \ud0a4\uc6cc\ub4dc \uc644\ubcbd \uc815\ub9ac: \ub0b4\ubd80 static vs \uc678\ubd80 static<\/h1>\n<p>C \uc5b8\uc5b4 \ubc0f C++ \ud504\ub85c\uadf8\ub798\ubc0d\uc744 \ubc30\uc6b0\ub2e4 \ubcf4\uba74 \uac00\uc7a5 \uc790\uc8fc \uc811\ud558\uba74\uc11c\ub3c4 \ucd08\ubcf4\uc790\ub4e4\uc774 \ud754\ud788 \ud5f7\uac08\ub824 \ud558\ub294 \ud0a4\uc6cc\ub4dc \uc911 \ud558\ub098\uac00 \ubc14\ub85c <code>static<\/code>\uc785\ub2c8\ub2e4.<\/p>\n<p>\ud754\ud788 Brian Kernighan\uacfc Dennis Ritchie\uac00 \uc9c0\uc740 C \uc5b8\uc5b4\uc758 \uae30\ubcf8\uc11c <strong>K&amp;R C (<em>The C Programming Language<\/em>)<\/strong>\uc758 <strong>4\uc7a5(Functions and Program Structure)<\/strong>\uc5d0\uc11c\ub3c4 <code>static<\/code> \ud0a4\uc6cc\ub4dc\ub294 \uc911\uc694\ud55c \uac1c\ub150\uc73c\ub85c \ub2e4\ub8e8\uc5b4\uc9d1\ub2c8\ub2e4. <\/p>\n<p>C\/C++\uc5d0\uc11c <code>static<\/code>\uc740 \uc120\uc5b8\ub418\ub294 <strong>\uc704\uce58(\ud568\uc218 \ub0b4\ubd80 vs \ud30c\uc77c \uc2a4\ucf54\ud504)<\/strong>\uc5d0 \ub530\ub77c \uc644\uc804\ud788 \ub2e4\ub978 \ub450 \uac00\uc9c0 \uc5ed\ud560\uc744 \uc218\ud589\ud569\ub2c8\ub2e4. \uc774\ubc88 \ud3ec\uc2a4\ud305\uc5d0\uc11c\ub294 <code>static<\/code> \ud0a4\uc6cc\ub4dc\uc758 \uac1c\ub150\uacfc \ub3d9\uc791 \ubc29\uc2dd, \uadf8\ub9ac\uace0 \uc2e4\ubb34\uc5d0\uc11c\uc758 \uc0ac\uc6a9 \uc608\uc81c\ub97c \uc815\ub9ac\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<hr \/>\n<h2>1. static \ud0a4\uc6cc\ub4dc\uc758 \ud575\uc2ec \uac1c\ub150<\/h2>\n<p><code>static<\/code> \ud0a4\uc6cc\ub4dc\ub294 \uae30\ubcf8\uc801\uc73c\ub85c \ub2e4\uc74c \ub450 \uac00\uc9c0 \uc18d\uc131\uc744 \uc81c\uc5b4\ud569\ub2c8\ub2e4.<\/p>\n<ol>\n<li><strong>\uc800\uc7a5 \uc218\uba85 (Storage Duration)<\/strong>: \ubcc0\uc218\uac00 \uba54\ubaa8\ub9ac\uc5d0 \uc720\uc9c0\ub418\ub294 \uae30\uac04 (\ud504\ub85c\uadf8\ub7a8 \uc2dc\uc791\ubd80\ud130 \uc885\ub8cc\uae4c\uc9c0)<\/li>\n<li><strong>\uc5f0\uacb0\uc131 \/ \uac00\uc2dc\uc131 (Linkage \/ Visibility)<\/strong>: \ud574\ub2f9 \uc2dd\ubcc4\uc790(\ubcc0\uc218 \ub610\ub294 \ud568\uc218)\ub97c \uc5b4\ub290 \ubc94\uc8fc\uae4c\uc9c0 \ucc38\uc870\ud560 \uc218 \uc788\ub294\uc9c0<\/li>\n<\/ol>\n<hr \/>\n<h2>2. \ub0b4\ubd80 static \ubcc0\uc218 (Internal Static Variables)<\/h2>\n<p><strong>\ud568\uc218 \ub0b4\ubd80<\/strong>\uc5d0 \uc120\uc5b8\ub41c <code>static<\/code> \ubcc0\uc218\uc785\ub2c8\ub2e4.<\/p>\n<h3>\ud2b9\uc9d5<\/h3>\n<ul>\n<li><strong>\uc218\uba85(Lifetime)<\/strong>: \ud568\uc218\uac00 \ud638\ucd9c\ub420 \ub54c \uc0dd\uc131\ub418\ub294 \uc77c\ubc18 \uc9c0\uc5ed \ubcc0\uc218(auto)\uc640 \ub2ec\ub9ac, <strong>\ud504\ub85c\uadf8\ub7a8\uc774 \uc2e4\ud589\ub420 \ub54c \uba54\ubaa8\ub9ac(Data\/BSS \uc601\uc5ed)\uc5d0 \ud560\ub2f9<\/strong>\ub418\uc5b4 \ud504\ub85c\uadf8\ub7a8\uc774 \uc885\ub8cc\ub420 \ub54c\uae4c\uc9c0 \ub0a8\uc544\uc788\uc2b5\ub2c8\ub2e4.<\/li>\n<li><strong>\ucd08\uae30\ud654<\/strong>: \ud504\ub85c\uadf8\ub7a8 \uc2dc\uc791 \uc2dc <strong>\ub2e8 \ud55c \ubc88\ub9cc \ucd08\uae30\ud654<\/strong>\ub429\ub2c8\ub2e4. (\ucd08\uae30\uac12\uc744 \uc9c0\uc815\ud558\uc9c0 \uc54a\uc73c\uba74 \uae30\ubcf8\uc801\uc73c\ub85c <code>0<\/code>\uc73c\ub85c \uc790\ub3d9 \ucd08\uae30\ud654)<\/li>\n<li><strong>\uc2a4\ucf54\ud504(Scope)<\/strong>: \ubcc0\uc218\uac00 \uc120\uc5b8\ub41c <strong>\ud568\uc218 \ub0b4\ubd80\uc5d0\uc11c\ub9cc \uc811\uadfc \uac00\ub2a5<\/strong>\ud569\ub2c8\ub2e4.<\/li>\n<\/ul>\n<h3>\ucf54\ub4dc \uc608\uc81c<\/h3>\n<pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n\nvoid count_calls() {\n    static int count = 0; \/\/ \ud504\ub85c\uadf8\ub7a8 \uc2dc\uc791 \uc2dc 1\ud68c\ub9cc \ucd08\uae30\ud654\ub428\n    int local_var = 0;    \/\/ \ud568\uc218 \ud638\ucd9c \uc2dc\ub9c8\ub2e4 \uc0dd\uc131 \ubc0f \ucd08\uae30\ud654\ub428\n\n    count++;\n    local_var++;\n\n    printf(&quot;static count: %d, local_var: %d\\n&quot;, count, local_var);\n}\n\nint main() {\n    count_calls(); \/\/ static count: 1, local_var: 1\n    count_calls(); \/\/ static count: 2, local_var: 1\n    count_calls(); \/\/ static count: 3, local_var: 1\n    return 0;\n}<\/code><\/pre>\n<h3>\uc5b8\uc81c \uc0ac\uc6a9\ud560\uae4c?<\/h3>\n<ul>\n<li>\ud568\uc218\uac00 \uc774\uc804 \ud638\ucd9c \uc0c1\ud0dc\ub97c \uae30\uc5b5\ud574\uc57c \ud560 \ub54c (\uc608: \ud638\ucd9c \ud69f\uc218 \uce74\uc6b4\ud305, \uce90\uc2f1, \uc0c1\ud0dc \uba38\uc2e0 \uad00\ub9ac)<\/li>\n<li>\uc804\uc5ed \ubcc0\uc218\ub97c \uc4f0\uae30\uc5d4 \ucea1\uc290\ud654\uac00 \uae68\uc9c0\uace0, \uc77c\ubc18 \uc9c0\uc5ed \ubcc0\uc218\ub97c \uc4f0\uae30\uc5d4 \uac12\uc774 \uc720\uc9c0\ub418\uc5b4\uc57c \ud560 \ub54c<\/li>\n<\/ul>\n<hr \/>\n<h2>3. \uc678\ubd80 static \ubcc0\uc218 \ubc0f \ud568\uc218 (External Static Variables &amp; Functions)<\/h2>\n<p><strong>\ud568\uc218 \uc678\ubd80(\ud30c\uc77c \uc2a4\ucf54\ud504)<\/strong>\uc5d0 \uc120\uc5b8\ub41c <code>static<\/code> \ubcc0\uc218 \ub610\ub294 \ud568\uc218\uc785\ub2c8\ub2e4.<\/p>\n<h3>\ud2b9\uc9d5<\/h3>\n<ul>\n<li><strong>\ub0b4\ubd80 \uc5f0\uacb0(Internal Linkage)<\/strong>\uc744 \uac00\uc9d1\ub2c8\ub2e4.<\/li>\n<li>\uc120\uc5b8\ub41c <strong>\ud574\ub2f9 \uc18c\uc2a4 \ud30c\uc77c(.c) \ub0b4\uc5d0\uc11c\ub9cc \ucc38\uc870<\/strong>\ud560 \uc218 \uc788\uc73c\uba70, \ub2e4\ub978 \ud30c\uc77c\uc5d0\uc11c <code>extern<\/code>\uc73c\ub85c \uc811\uadfc\ud558\ub294 \uac83\uc774 \ubd88\uac00\ub2a5\ud569\ub2c8\ub2e4.<\/li>\n<li>\ud30c\uc77c \uac04\uc758 \uc774\ub984 \ucda9\ub3cc\uc744 \ubc29\uc9c0\ud558\uace0 <strong>\uc815\ubcf4 \uc740\ub2c9(Information Hiding) \ubc0f \ubaa8\ub4c8\ud654<\/strong>\ub97c \uad6c\ud604\ud558\ub294 \ub370 \uc4f0\uc785\ub2c8\ub2e4.<\/li>\n<\/ul>\n<h3>\ucf54\ub4dc \uc608\uc81c<\/h3>\n<h4><code>math_utils.c<\/code><\/h4>\n<pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n\n\/\/ \uc774 \ud30c\uc77c \ub0b4\ubd80\uc5d0\uc11c\ub9cc \uc811\uadfc \uac00\ub2a5\ud55c static \uc804\uc5ed \ubcc0\uc218\nstatic int operation_count = 0;\n\n\/\/ \uc774 \ud30c\uc77c \ub0b4\ubd80\uc5d0\uc11c\ub9cc \ud638\ucd9c \uac00\ub2a5\ud55c static \ud5ec\ud37c \ud568\uc218\nstatic void log_operation(const char* op_name) {\n    operation_count++;\n    printf(&quot;[%s] \uc218\ud589\ub428 (\ucd1d \uc2e4\ud589 \ud69f\uc218: %d)\\n&quot;, op_name, operation_count);\n}\n\nint add(int a, int b) {\n    log_operation(&quot;Add&quot;);\n    return a + b;\n}<\/code><\/pre>\n<h4><code>main.c<\/code><\/h4>\n<pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n\nint add(int a, int b);\n\n\/\/ \uc544\ub798\uc640 \uac19\uc774 \uac00\uc838\uc624\ub824\uace0 \uc2dc\ub3c4\ud558\uba74 \ub9c1\ucee4 \uc5d0\ub7ec(Link Error) \ubc1c\uc0dd!\n\/\/ extern int operation_count; \n\/\/ void log_operation(const char* op_name);\n\nint main() {\n    printf(&quot;Result: %d\\n&quot;, add(3, 5));\n    printf(&quot;Result: %d\\n&quot;, add(10, 20));\n    return 0;\n}<\/code><\/pre>\n<h3>\uc5b8\uc81c \uc0ac\uc6a9\ud560\uae4c?<\/h3>\n<ul>\n<li>\ud2b9\uc815 \ubaa8\ub4c8\/\ud30c\uc77c \ub0b4\ubd80\uc5d0\uc11c\ub9cc \uc0ac\uc6a9\ud558\ub294 \ud5ec\ud37c \ud568\uc218\ub098 \uc0c1\ud0dc \ubcc0\uc218\ub97c \uc228\uae30\uace0 \uc2f6\uc744 \ub54c<\/li>\n<li>\ub77c\uc774\ube0c\ub7ec\ub9ac \uc791\uc131 \uc2dc \uc678\ubd80\ub85c \ub178\ucd9c\ud558\ub294 API\uc640 \ub0b4\ubd80 \uad6c\ud604 \ub85c\uc9c1\uc744 \ubd84\ub9ac\ud560 \ub54c<\/li>\n<\/ul>\n<hr \/>\n<h2>4. \uc694\uc57d \uc815\ub9ac<\/h2>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\uad6c\ubd84<\/th>\n<th style=\"text-align: left;\">\uc704\uce58<\/th>\n<th style=\"text-align: left;\">\uc218\uba85 (Duration)<\/th>\n<th style=\"text-align: left;\">\uc2a4\ucf54\ud504\/\uac00\uc2dc\uc131 (Scope\/Visibility)<\/th>\n<th style=\"text-align: left;\">\uc8fc\uc694 \ubaa9\uc801<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>\ub0b4\ubd80 static<\/strong><\/td>\n<td style=\"text-align: left;\">\ud568\uc218 \ub0b4\ubd80<\/td>\n<td style=\"text-align: left;\">\ud504\ub85c\uadf8\ub7a8 \uc804\uccb4 (Data \uc601\uc5ed)<\/td>\n<td style=\"text-align: left;\">\ud574\ub2f9 \ud568\uc218 \ub0b4\ubd80<\/td>\n<td style=\"text-align: left;\">\ud568\uc218 \ud638\ucd9c \uac04 \uc0c1\ud0dc \uc720\uc9c0<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\uc678\ubd80 static<\/strong><\/td>\n<td style=\"text-align: left;\">\ud568\uc218 \uc678\ubd80 (\ud30c\uc77c \ub2e8\uc704)<\/td>\n<td style=\"text-align: left;\">\ud504\ub85c\uadf8\ub7a8 \uc804\uccb4 (Data \uc601\uc5ed)<\/td>\n<td style=\"text-align: left;\">\ud574\ub2f9 \ud30c\uc77c \ub0b4\ubd80 (<code>Internal Linkage<\/code>)<\/td>\n<td style=\"text-align: left;\">\ubaa8\ub4c8\ud654, \uc815\ubcf4 \uc740\ub2c9, \uc774\ub984 \ucda9\ub3cc \ubc29\uc9c0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\ub9c8\uce58\uba70<\/h2>\n<p>C\/C++\uc758 <code>static<\/code> \ud0a4\uc6cc\ub4dc\ub294 <strong>&quot;\uba54\ubaa8\ub9ac \uc0c1\uc5d0\ub294 \uacc4\uc18d \uc874\uc7ac\ud558\uac8c \ud558\ub418, \uc811\uadfc \ubc94\uc704\ub294 \uc81c\ud55c\ud55c\ub2e4&quot;<\/strong>\ub294 \uacf5\ud1b5\ub41c \uc6d0\ub9ac\ub85c \uc791\ub3d9\ud569\ub2c8\ub2e4.<\/p>\n<ol>\n<li><strong>\ud568\uc218 \ub0b4\ubd80<\/strong>: \uc804\uc5ed \uba54\ubaa8\ub9ac\uc5d0 \ub450\ub418, \uc811\uadfc\uc740 \ud574\ub2f9 <strong>\ud568\uc218<\/strong>\ub85c \uc81c\ud55c<\/li>\n<li><strong>\ud30c\uc77c \uc678\ubd80<\/strong>: \uc804\uc5ed \uba54\ubaa8\ub9ac\uc5d0 \ub450\ub418, \uc811\uadfc\uc740 \ud574\ub2f9 <strong>\ud30c\uc77c<\/strong>\ub85c \uc81c\ud55c<\/li>\n<\/ol>\n<p>\uc774 \ub450 \uac00\uc9c0 \uc4f0\uc784\uc0c8\ub97c \uba85\ud655\ud788 \uc774\ud574\ud558\uace0 \ud65c\uc6a9\ud55c\ub2e4\uba74, \ubcf4\ub2e4 \uc548\uc804\ud558\uace0 \ubaa8\ub4c8\ud654\ub41c \uae54\ub054\ud55c C\/C++ \ucf54\ub4dc\ub97c \uc791\uc131\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C\/C++ static \ud0a4\uc6cc\ub4dc \uc644\ubcbd \uc815\ub9ac: \ub0b4\ubd80 static vs \uc678\ubd80 static C \uc5b8\uc5b4 \ubc0f C++ \ud504\ub85c\uadf8\ub798\ubc0d\uc744 \ubc30\uc6b0\ub2e4 \ubcf4\uba74 \uac00\uc7a5 \uc790\uc8fc \uc811\ud558\uba74\uc11c\ub3c4 \ucd08\ubcf4\uc790\ub4e4\uc774 \ud754\ud788 \ud5f7\uac08\ub824 \ud558\ub294 \ud0a4\uc6cc\ub4dc \uc911 \ud558\ub098\uac00 \ubc14\ub85c static\uc785\ub2c8\ub2e4. \ud754\ud788 Brian Kernighan\uacfc Dennis Ritchie\uac00 \uc9c0\uc740 C \uc5b8\uc5b4\uc758 \uae30\ubcf8\uc11c K&amp;R C (The C Programming Language)\uc758 4\uc7a5(Functions and Program Structure)\uc5d0\uc11c\ub3c4 static \ud0a4\uc6cc\ub4dc\ub294 \uc911\uc694\ud55c \uac1c\ub150\uc73c\ub85c \ub2e4\ub8e8\uc5b4\uc9d1\ub2c8\ub2e4. C\/C++\uc5d0\uc11c static\uc740\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11806\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-11806","post","type-post","status-publish","format-standard","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11806"}],"version-history":[{"count":1,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11806\/revisions"}],"predecessor-version":[{"id":11807,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11806\/revisions\/11807"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}