{"id":6264,"date":"2017-02-02T23:55:10","date_gmt":"2017-02-02T14:55:10","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6264"},"modified":"2017-02-04T04:54:00","modified_gmt":"2017-02-03T19:54:00","slug":"gcc-%e3%81%ae%e3%82%a4%e3%83%b3%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%a2%e3%82%bb%e3%83%b3%e3%83%96%e3%83%a9%e3%81%a8-c11-%e3%81%ae%e7%94%9f%e6%96%87%e5%ad%97%e5%88%97%e3%83%aa%e3%83%86%e3%83%a9%e3%83%ab","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6264","title":{"rendered":"GCC \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u3068 C++11 \u306e\u751f\u6587\u5b57\u5217\u30ea\u30c6\u30e9\u30eb"},"content":{"rendered":"<p>GCC \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u69cb\u6587\u3092\u3057\u3066\u3044\u307e\u3059\u3002(<a href=\"https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Extended-Asm.html\">https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Extended-Asm.html<\/a>)<\/p>\n<p><!--more--><\/p>\n<blockquote>\n<pre>\r\nasm [volatile] ( AssemblerTemplate\r\n                      : OutputOperands\r\n                      [ : InputOperands\r\n                      [ : Clobbers ] ])\r\n<\/pre>\n<\/blockquote>\n<p>AssemblerTemplate \u306e\u90e8\u5206\u304c\u30a2\u30bb\u30f3\u30d6\u30ea\u8a00\u8a9e\u3067\u66f8\u304f\u90e8\u5206\u3067\u3059\u304c\u3001Visual C++ \u306a\u3069\u3068\u306f\u9055\u3063\u3066\u3053\u3053\u306f\u6587\u5b57\u5217\u30ea\u30c6\u30e9\u30eb\u3092\u66f8\u304f\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u4f8b\u3048\u3070\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u4ee5\u4e0b\u3001\u4f8b\u306f\u5168\u3066 <code>-masm=intel<\/code> \u306b\u3088\u308b Intel \u8a18\u6cd5\uff09<\/p>\n<blockquote>\n<pre>asm volatile(\r\n    \"cpuid\"\r\n    : \"=a\"(dst)\r\n    : \"a\"(src));<\/pre>\n<\/blockquote>\n<p>\u8907\u6570\u884c\u306b\u306a\u308b\u5834\u5408\u306f\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>asm volatile(\r\n    \"xor eax, eax\\n\\t\"\r\n    \"cpuid\"\r\n    : \"=a\"(dst));<\/pre>\n<\/blockquote>\n<p>\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u306f AssemblerTemplate \u306e\u90e8\u5206\u3092\u591a\u5c11\u4fee\u98fe\u3057\u3066\u304b\u3089\u305d\u306e\u307e\u307eC\u8a00\u8a9e\u306e\u90e8\u5206\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u305f\u7d50\u679c\u3068\u4e00\u7dd2\u306b\u30a2\u30bb\u30f3\u30d6\u30ea\u30bd\u30fc\u30b9\u306b\u57cb\u3081\u8fbc\u307f\u3001\u305d\u308c\u304c\u30a2\u30bb\u30f3\u30d6\u30e9\u306b\u56de\u3055\u308c\u308b\u3001\u3068\u3044\u3046\u6319\u52d5\u3092\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001<code>\\n<\/code> \u304c\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u3068\u30a2\u30bb\u30f3\u30d6\u30e9\u304b\u3089\u306f2\u884c\u3068\u898b\u306a\u3055\u308c\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u5b9f\u969b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304f\u3068\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>asm volatile(\r\n    \"xor eax, eax\"\r\n    \"cpuid\"\r\n    : \"=a\"(dst));<\/pre>\n<\/blockquote>\n<blockquote>\n<pre>\/usr\/lib\/gcc\/x86_64-redhat-linux\/4.4.7\/..\/..\/..\/..\/lib64\/crt1.o: In function `_start':\r\n(.text+0x20): undefined reference to `main'\r\n\/tmp\/ccWJ7Odd.o: In function `foo(unsigned int)':\r\natest.c:(.text+0xd): undefined reference to `eaxcpuid'\r\ncollect2: ld returned 1 exit status<\/pre>\n<\/blockquote>\n<p>\u3053\u308c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u3044\u305f\u306e\u3068\u540c\u3058\u3068\u898b\u306a\u3055\u308c\u3066\u3044\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<blockquote>\n<pre>asm volatile(\r\n    \"xor eax, eaxcpuid\"\r\n    : \"=a\"(dst));<\/pre>\n<\/blockquote>\n<p>\u6b8b\u5ff5\u306a\u304c\u3089\uff1f C \u3067\u306f\u6539\u884c\u3084\u30c0\u30d6\u30eb\u30af\u30aa\u30fc\u30c8\u3084\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u3092\uff08\u30a8\u30b9\u30b1\u30fc\u30d7\u305b\u305a\u306b\uff09\u6587\u5b57\u5217\u30ea\u30c6\u30e9\u30eb\u306b\u542b\u3081\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u884c\u672b\u306b <code>\\<\/code> \u3092\u66f8\u3044\u3066\u304a\u3051\u3070\u3088\u3044\u304b\u3068\u8a00\u3046\u3068\u305d\u3093\u306a\u3053\u3068\u306f\u7121\u304f\u3066\u3001\u3053\u308c\u306f\u5358\u306b1\u3064\u306e\u9577\u3044\u884c\u3068\u3057\u3066\u6271\u308f\u308c\u307e\u3059\u3002\u7d50\u5c40 <code>\\n<\/code> \u306f\u5fc5\u9808\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u307e\u3067\u524d\u7f6e\u304d\u3002<\/p>\n<p>\u3055\u3066\u3001 C++11 \u306b\u306f<a href=\"https:\/\/cpprefjp.github.io\/lang\/cpp11\/raw_string_literals.html\">\u300c\u751f\u6587\u5b57\u5217\u30ea\u30c6\u30e9\u30eb\u300d (raw string literals)<\/a> \u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u3001\u4efb\u610f\u306e\u6587\u5b57\u30b7\u30fc\u30b1\u30f3\u30b9\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u4e0d\u8981\u3067\u6587\u5b57\u5217\u30ea\u30c6\u30e9\u30eb\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3082\u3061\u308d\u3093\u6539\u884c\u3082\u4f8b\u5916\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u306a\u306e\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>asm volatile(\r\n    <strong>R\"(<\/strong>\r\n    xor eax, eax\r\n    cpuid\r\n    <strong>)\"<\/strong>\r\n    : \"=a\"(dst));<\/pre>\n<\/blockquote>\n<p>\u884c\u3054\u3068\u306e\u30c0\u30d6\u30eb\u30af\u30aa\u30fc\u30c8\u3082 <code>\\n<\/code> \u3082\u6392\u9664\u3055\u308c\u3001\u3068\u3066\u3082\u8aad\u307f\u3084\u3059\u304f\u306a\u308a\u307e\u3057\u305f\u3002\u3084\u3063\u305f\u305c\u3002<\/p>\n<p>\u3048\u3063\u3001\u751fC\u3067\u306f\u3069\u3046\u3059\u308b\u306e\u304b\u3063\u3066\uff1f \u3055\u3042\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GCC \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u69cb\u6587\u3092\u3057\u3066\u3044\u307e\u3059\u3002(https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Extended-Asm.html)<\/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-6264","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\/6264","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=6264"}],"version-history":[{"count":14,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6264\/revisions"}],"predecessor-version":[{"id":6279,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6264\/revisions\/6279"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6264"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}