{"id":316,"date":"2023-02-22T02:32:27","date_gmt":"2023-02-22T10:32:27","guid":{"rendered":"http:\/\/bitas.net.cn\/?page_id=316"},"modified":"2023-03-10T18:00:57","modified_gmt":"2023-03-11T02:00:57","slug":"114-2","status":"publish","type":"page","link":"http:\/\/bitas.net.cn\/index.php\/sourcecode\/114-2\/","title":{"rendered":"114 \u6807\u8bc6\u7b26\u7684\u94fe\u63a5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>lifetime.c<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include \"otherfile.h\"\n\n\/\/extern int step;  \/\/ has no effect\n\nstatic void hide_exobj()\n{\n    int exobj;\n    printf(\"exobj(hide_exobj) address: %p\\n\",\n        &amp;exobj);\n}\n\nint main(int argc, char *argv&#91;])\n{\n    extern int exobj;\n\n    printf(\"exobj(main) address: %p\\n\",\n        &amp;exobj);\n    hide_exobj();\n\n    \/\/printf(\"step is %d\\n\", step);\n\n    printf(\"original exobj is %d\\n\",\n        exobj);\n    printf(\"add exobj by 1\\n\");\n    exobj++;\n    printf(\"exobj becomes %d\\n\",\n        exobj);\n\n    inc_exobj();\n    dec_exobj();\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">otherfile.h<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#ifndef OTHERFILE_H_\n#define OTHERFILE_H_\n\nextern int exobj;\nextern void inc_exobj();\nextern void dec_exobj();\n\n#endif<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">otherfile1.c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n\nint exobj = 0;\n\/\/static int exobj;  \/\/ error\nstatic int step = 1;\nextern int step;  \/\/ has no effect\n\nstatic void step_exobj()\n{\n    exobj += step;\n}\n\nvoid inc_exobj()\n{\n    step_exobj();\n    printf(\"increased exobj: %d\\n\",\n        exobj);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">otherfile2.c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n\nextern int exobj;\nstatic int step = -1; \n\nstatic void step_exobj()\n{\n    exobj += step;\n}\n\nvoid dec_exobj()\n{\n    step_exobj();\n    printf(\"decreaseed exobj: %d\\n\",\n        exobj);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>lifetime.c otherfile.h otherfile1.c otherfile2.c<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":127,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-316","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/comments?post=316"}],"version-history":[{"count":2,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/316\/revisions"}],"predecessor-version":[{"id":416,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/316\/revisions\/416"}],"up":[{"embeddable":true,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/127"}],"wp:attachment":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/media?parent=316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}