{"id":6163,"date":"2016-12-12T23:06:31","date_gmt":"2016-12-12T14:06:31","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6163"},"modified":"2016-12-16T00:44:47","modified_gmt":"2016-12-15T15:44:47","slug":"windows-%e4%b8%8a%e3%81%a7%e3%81%ae-visual-c-%e3%81%a8-gccclang-%e3%81%ae%e7%9b%b8%e4%ba%92%e9%81%8b%e7%94%a8%ef%bc%88%e3%81%9d%e3%81%ae%ef%bc%95%ef%bc%89","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6163","title":{"rendered":"Windows \u4e0a\u3067\u306e Visual C++ \u3068 GCC\/Clang \u306e\u76f8\u4e92\u904b\u7528\uff08\u305d\u306e\uff15\uff09"},"content":{"rendered":"<p><a href=\"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6145\">\u305d\u306e\uff14<\/a>\u306e\u7d9a\u304d<\/p>\n<p>C++ \u3060\u3068\u3069\u3046\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><!--more--><\/p>\n<blockquote>\n<pre>umezawa@selene ~$ cat callee_cpp.cc\r\nint func_cpp(int x, int y, int z)\r\n{\r\n        return x * y + z;\r\n}\r\n\r\numezawa@selene ~$ cat main_cpp.cpp\r\n#include &lt;stdio.h&gt;\r\n\r\nint func_cpp(int x, int y, int z);\r\n\r\nint main(void)\r\n{\r\n        printf(\"%d\\n\", func_cpp(2, 3, 4));\r\n        return 0;\r\n}\r\n\r\numezawa@selene ~$ g++ -o callee_cpp_gcc.obj -c callee_cpp.cc\r\n<\/pre>\n<\/blockquote>\n<blockquote>\n<pre>c:\\cygwin\\home\\umezawa&gt;cl \/Fea5.exe main_cpp.cpp callee_cpp_gcc.obj\r\nMicrosoft(R) C\/C++ Optimizing Compiler Version 19.00.24215.1 for x86\r\nCopyright (C) Microsoft Corporation.  All rights reserved.\r\n\r\nmain_cpp.cpp\r\nMicrosoft (R) Incremental Linker Version 14.00.24215.1\r\nCopyright (C) Microsoft Corporation.  All rights reserved.\r\n\r\n\/out:a5.exe\r\nmain_cpp.obj\r\ncallee_cpp_gcc.obj\r\nmain_cpp.obj : error LNK2019: \u672a\u89e3\u6c7a\u306e\u5916\u90e8\u30b7\u30f3\u30dc\u30eb \"int __cdecl func_cpp(int,int,int)\" (<strong>?func_cpp@@YAHHHH@Z<\/strong>) \u304c\u95a2\u6570 _main \u3067\u53c2\u7167\u3055\u308c\u307e\u3057\u305f\u3002\r\na5.exe : fatal error LNK1120: 1 \u4ef6\u306e\u672a\u89e3\u6c7a\u306e\u5916\u90e8\u53c2\u7167<\/pre>\n<\/blockquote>\n<p>\u30ea\u30f3\u30af\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>objdump \u3067\u898b\u3066\u307f\u308b\u3068\u3001\u540d\u524d\u4fee\u98fe\u898f\u5247\u304c\u7570\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>umezawa@selene ~$ objdump --syms callee_cpp_gcc.obj\r\n\r\ncallee_cpp_gcc.obj:     \u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f pe-i386\r\n\r\nSYMBOL TABLE:\r\n[  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x00000000 callee_cpp.cc\r\nFile\r\n[  2](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 1) 0x00000000 <strong>__Z8func_cppiii<\/strong>\r\nAUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0\r\n[  4](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text\r\nAUX scnlen 0x13 nreloc 0 nlnno 0\r\n[  6](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .data\r\nAUX scnlen 0x0 nreloc 0 nlnno 0\r\n[  8](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss\r\nAUX scnlen 0x0 nreloc 0 nlnno 0\r\n[ 10](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .rdata$zzz\r\nAUX scnlen 0x11 nreloc 0 nlnno 0\r\n[ 12](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .eh_frame\r\nAUX scnlen 0x38 nreloc 1 nlnno 0\r\n<\/pre>\n<\/blockquote>\n<p>\u30b0\u30b0\u3063\u3066\u307f\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3068\u3001\u4fee\u98fe\u5f8c\u306e\u540d\u524d\u3092\u76f4\u63a5\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<blockquote>\n<pre>umezawa@selene ~$ cat callee_cpp2.cc\r\nint func_cpp(int x, int y, int z) <strong>__asm__(\"_mangled_name\");<\/strong>\r\nint func_cpp(int x, int y, int z)\r\n{\r\n        return x * y + z;\r\n}\r\n\r\numezawa@selene ~$ g++ -o callee_cpp2_gcc.obj -c callee_cpp2.cc\r\n\r\numezawa@selene ~$ objdump --syms callee_cpp2_gcc.obj\r\n\r\ncallee_cpp2_gcc.obj:     \u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f pe-i386\r\n\r\nSYMBOL TABLE:\r\n[  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x00000000 callee_cpp2.cc\r\nFile\r\n[  2](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 1) 0x00000000 <strong>_mangled_name<\/strong>\r\nAUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0\r\n[  4](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text\r\nAUX scnlen 0x13 nreloc 0 nlnno 0\r\n[  6](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .data\r\nAUX scnlen 0x0 nreloc 0 nlnno 0\r\n[  8](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss\r\nAUX scnlen 0x0 nreloc 0 nlnno 0\r\n[ 10](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .rdata$zzz\r\nAUX scnlen 0x11 nreloc 0 nlnno 0\r\n[ 12](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .eh_frame\r\nAUX scnlen 0x38 nreloc 1 nlnno 0\r\n<\/pre>\n<\/blockquote>\n<p>\u3067\u3059\u304c\u3001\u540d\u524d\u306b <code>?<\/code> \u3084 <code>@<\/code> \u304c\u542b\u307e\u308c\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u305f\u3081\u3001Visual C++ \u3068\u4e92\u63db\u6027\u306e\u3042\u308b\u540d\u524d\u306b\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u3067\u304d\u305f\u3068\u3057\u3066\u3082\u5168\u3066\u306e\u95a2\u6570\u306b\u3064\u3044\u3066 Visual C++ \u3067\u306e\u4fee\u98fe\u5f8c\u306e\u540d\u524d\u3092\u8abf\u3079\u308b\u4f5c\u696d\u304c\u767a\u751f\u3057\u3001\u3081\u3093\u3069\u304f\u3055\u3044\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><code>extern \"C\"<\/code> \u3057\u3066\u3044\u308b\u5834\u5408\u306f\u30d5\u30ea\u30fc\u95a2\u6570\u306b\u3064\u3044\u3066\u306f\u540d\u524d\u4fee\u98fe\u3092 Visual C++ \u3068\u4e92\u63db\u6027\u306e\u3042\u308b\u3082\u306e\uff08C \u306e\u3082\u306e\uff09\u306b\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u3046\u3057\u305f\u5834\u5408\u95a2\u6570\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306f\u3067\u304d\u307e\u305b\u3093\u3057\u3001<code>extern \"C\"<\/code> \u306f\u30af\u30e9\u30b9\u306e\u30e1\u30f3\u30d0\u95a2\u6570\u306b\u5bfe\u3057\u3066\u306f\u4f7f\u3048\u307e\u305b\u3093\u3002\u304a\u3068\u306a\u3057\u304f C++ \u3067\u306f\u8ae6\u3081\u305f\u65b9\u304c\u3088\u3055\u305d\u3046\u3067\u3059\u3002\u3053\u308c\u4ee5\u4e0a\u8abf\u3079\u308b\u306e\u9762\u5012\u3060\u3057\uff08\u672c\u97f3\uff09<\/p>\n<p><a href=\"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6173\">\u305d\u306e\uff16<\/a>\u306b\u7d9a\u304f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u305d\u306e\uff14\u306e\u7d9a\u304d C++ \u3060\u3068\u3069\u3046\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-6163","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6163"}],"version-history":[{"count":8,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6163\/revisions"}],"predecessor-version":[{"id":6178,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6163\/revisions\/6178"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6163"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}