{"id":896,"date":"2011-06-24T02:23:09","date_gmt":"2011-06-23T17:23:09","guid":{"rendered":"http:\/\/helloidea.org\/?p=896"},"modified":"2015-04-27T04:30:54","modified_gmt":"2015-04-26T19:30:54","slug":"extern-c-%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/helloidea.org\/index.php\/archives\/896.html","title":{"rendered":"extern \u201cC\u201d \u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>\u306a\u305c extern &#8220;C&#8221; \u3092\u4f7f\u3046\u306e\u304b\u3002<br \/>\n\u30e1\u30e2\u30e1\u30e2\u3002\u3002<\/p>\n<p>C++\u3068C\u3067\u306f\u30e9\u30d9\u30eb\u306e\u547d\u540d\u898f\u5247\u304c\u9055\u3046\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>C\u3067<br \/>\ntest(){};<br \/>\n\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u30a2\u30bb\u30f3\u30d6\u30ea\u3067\u306f _test: \u30e9\u30d9\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059<\/p>\n<p>C++\u3067<br \/>\ntest(){};<br \/>\n\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u30a2\u30bb\u30f3\u30d6\u30ea\u3067\u306f __Z4testv: \u30e9\u30d9\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059<\/p>\n<p>C++\u304b\u3089test\u95a2\u6570\u3092\u547c\u307c\u3046\u3068\u3059\u308b\u3068__Z4testv:\u3092\u63a2\u3057\u307e\u3059\u3002<br \/>\n\u3059\u308b\u3068\u3001\u5f53\u7136\u306b\u30e9\u30d9\u30eb\u304c\u5b58\u5728\u3057\u306a\u3044\u306e\u3067\u30ea\u30f3\u30ab\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002 <\/p>\n<p>\u305d\u3053\u3067 extern &#8220;C&#8221; \u3092\u4f7f\u3046\u3068\u3001C++\u304b\u3089test\u95a2\u6570\u3092\u547c\u307c\u3046\u3068\u3059\u308b\u3068_test:\u3092\u63a2\u3057\u307e\u3059\u3002<br \/>\n\u3059\u308b\u3068\u3001\u30e9\u30d9\u30eb\u304c\u5b58\u5728\u3059\u308b\u306e\u3067\u554f\u984c\u306a\u304f\u30ea\u30f3\u30af\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30f3\u30d7\u30eb<br \/>\ntest.h<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/* C Header *\/\r\n#ifndef TEST_H_\r\n#define TEST_H_\r\n\r\n#ifdef __cplusplus\r\nextern &quot;C&quot; {\r\n#endif\r\n\r\nvoid test();\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif \/* TEST_H_ *\/\r\n\r\n<\/pre>\n<p>test.c<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/* C Source *\/\r\n#include &quot;test.h&quot;\r\n\r\nvoid test()\r\n{\r\n\r\n}\r\n<\/pre>\n<p>testp.cpp<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/* C++ Source *\/\r\n#include &quot;test.h&quot;\r\n\r\nvoid aaa()\r\n{\r\n\r\n}\r\n\r\nint main()\r\n{\r\n\r\n\taaa();\r\n\r\n\ttest();\r\n\r\n\treturn 0;\r\n}\r\n\r\n<\/pre>\n<p>test.s<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\t.text\r\n\t.align 2\r\n.globl _test\r\n\t.def\t_test;\t.scl\t2;\t.type\t32;\t.endef\r\n_test:\r\n\tpushl\t%ebp\r\n\tmovl\t%esp, %ebp\r\n\tpopl\t%ebp\r\n\tret\r\n\r\n<\/pre>\n<p>\u25a0 extern &#8220;C&#8221; \u3042\u308a<br \/>\ntestp.s<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\t.text\r\n\t.align 2\r\n.globl __Z3aaav\r\n\t.def\t__Z3aaav;\t.scl\t2;\t.type\t32;\t.endef\r\n__Z3aaav:\r\n\tpushl\t%ebp\r\n\tmovl\t%esp, %ebp\r\n\tpopl\t%ebp\r\n\tret\r\n\t.def\t___main;\t.scl\t2;\t.type\t32;\t.endef\r\n\t.align 2\r\n.globl _main\r\n\t.def\t_main;\t.scl\t2;\t.type\t32;\t.endef\r\n_main:\r\n\tpushl\t%ebp\r\n\tmovl\t%esp, %ebp\r\n\tsubl\t$8, %esp\r\n\tandl\t$-16, %esp\r\n\tmovl\t$0, %eax\r\n\taddl\t$15, %eax\r\n\taddl\t$15, %eax\r\n\tshrl\t$4, %eax\r\n\tsall\t$4, %eax\r\n\tmovl\t%eax, -4(%ebp)\r\n\tmovl\t-4(%ebp), %eax\r\n\tcall\t__alloca\r\n\tcall\t___main\r\n\tcall\t__Z3aaav\r\n\tcall\t_test\r\n\tmovl\t$0, %eax\r\n\tleave\r\n\tret\r\n\t.def\t_test;\t.scl\t3;\t.type\t32;\t.endef\r\n\r\n<\/pre>\n<p>\u25a0 extern &#8220;C&#8221; \u306a\u3057<br \/>\ntestp.s<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\t.text\r\n\t.align 2\r\n.globl __Z3aaav\r\n\t.def\t__Z3aaav;\t.scl\t2;\t.type\t32;\t.endef\r\n__Z3aaav:\r\n\tpushl\t%ebp\r\n\tmovl\t%esp, %ebp\r\n\tpopl\t%ebp\r\n\tret\r\n\t.def\t___main;\t.scl\t2;\t.type\t32;\t.endef\r\n\t.align 2\r\n.globl _main\r\n\t.def\t_main;\t.scl\t2;\t.type\t32;\t.endef\r\n_main:\r\n\tpushl\t%ebp\r\n\tmovl\t%esp, %ebp\r\n\tsubl\t$8, %esp\r\n\tandl\t$-16, %esp\r\n\tmovl\t$0, %eax\r\n\taddl\t$15, %eax\r\n\taddl\t$15, %eax\r\n\tshrl\t$4, %eax\r\n\tsall\t$4, %eax\r\n\tmovl\t%eax, -4(%ebp)\r\n\tmovl\t-4(%ebp), %eax\r\n\tcall\t__alloca\r\n\tcall\t___main\r\n\tcall\t__Z3aaav\r\n\tcall\t__Z4testv\r\n\tmovl\t$0, %eax\r\n\tleave\r\n\tret\r\n\t.def\t__Z4testv;\t.scl\t3;\t.type\t32;\t.endef\r\n\r\n<\/pre>\n<p>C++\u3067\u306f\u540c\u3058\u95a2\u6570\u540d\u304c\u5229\u7528\u3067\u304d\u308b\u306e\u3067\u547d\u540d\u898f\u5247\u304c\u8907\u96d1\u306b\u306a\u3063\u3066\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b<br \/>\nextern &#8220;c&#8221; \u3058\u3083\u306a\u304f\u3066<br \/>\nextenn &#8220;C&#8221; \u3068\u3044\u3046\u3053\u3068\u306b\u6ce8\u610f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306a\u305c extern &#8220;C&#8221; \u3092\u4f7f\u3046\u306e\u304b\u3002 \u30e1\u30e2\u30e1\u30e2\u3002\u3002 C++\u3068C\u3067\u306f\u30e9\u30d9\u30eb\u306e\u547d\u540d\u898f\u5247\u304c\u9055\u3046\u3088\u3046\u3067\u3059\u3002 C\u3067 test(){}; \u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u30a2\u30bb\u30f3\u30d6\u30ea\u3067\u306f _test: \u30e9\u30d9\u30eb\u304c\u751f\u6210\u3055\u308c\u307e \u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-896","post","type-post","status-publish","format-standard","hentry","category-memo"],"_links":{"self":[{"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/posts\/896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/comments?post=896"}],"version-history":[{"count":14,"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/posts\/896\/revisions"}],"predecessor-version":[{"id":1492,"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/posts\/896\/revisions\/1492"}],"wp:attachment":[{"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/media?parent=896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/categories?post=896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/helloidea.org\/index.php\/wp-json\/wp\/v2\/tags?post=896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}