{"id":184,"date":"2013-07-13T02:14:37","date_gmt":"2013-07-13T02:14:37","guid":{"rendered":"http:\/\/www.cclo.idv.tw:8080\/blogs\/wordpress\/?p=184"},"modified":"2021-11-15T16:32:10","modified_gmt":"2021-11-15T08:32:10","slug":"_httpswwwfacebookcomgroupsprog","status":"publish","type":"post","link":"https:\/\/blog.cclo.idv.tw\/?p=184","title":{"rendered":"C++ bool \u6240\u5360\u7684\u8a18\u61b6\u9ad4\u7a7a\u9593\u8207\u8cc7\u6599\u5c0d\u9f4a (data alignment)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p>\u9019\u7bc7\u6587\u7ae0\u7684\u5167\u5bb9\uff0c\u7de3\u8d77\u65bc\u300c\u7a0b\u5f0f\u4eba\u96dc\u8a8c\u300d\u8a0e\u8ad6\u5340\u7684<a href=\"https:\/\/www.facebook.com\/groups\/programmerMagazine\/672193329464053\/?notif_t=group_comment_reply\">\u9019\u500b\u8a0e\u8ad6\u4e32<\/a>\u3002\u9019\u500b\u8a0e\u8ad6\u4e32\u5230\u6700\u5f8c\u5df2\u7d93\u5931\u7126\u4e86\uff0c\u4e0d\u904e\u6709\u5e7e\u500b\u91cd\u9ede\u662f\u503c\u5f97\u63d0\u51fa\u4f86\u8a0e\u8ad6\u7684\uff0c\u65bc\u662f\u9806\u624b\u6574\u7406\u51fa\u5e7e\u500b\u91cd\u9ede\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">bool \u6240\u5360\u7684\u8a18\u61b6\u9ad4\u7a7a\u9593<\/h2>\n\n\n\n<p>C++ \u5167\u5efa\u7684\u6a19\u6e96\u7684\u578b\u5225\u4e2d\uff0c\u6709\u4e00\u500b\u53eb <code>bool<\/code> \u7684\u578b\u5225\uff0c\u7528\u4f86\u5132\u5b58\u908f\u8f2f\u904b\u7b97\u7684 <code>true<\/code>\uff08\u771f\uff09\u8207 <code>false<\/code>\uff08\u5047\uff09\u3002\u7531\u65bc\u9019\u7a2e\u578b\u5225\u7684\u8b8a\u6578\u5c31\u53ea\u6703\u6709 <code>true<\/code> \u6216 <code>false<\/code> \u9019\u5169\u7a2e\u53ef\u80fd\u7684\u503c\uff0c\u56e0\u6b64\uff0c\u82e5\u662f\u6211\u5011\u8981\u5132\u5b58\u9019\u6a23\u7684\u8b8a\u6578\u7684\u8a71\uff0c\u7406\u8ad6\u4e0a\u4f86\u8aaa\u5176\u5be6\u53ea\u8981 1 \u500b bit \u5c31\u5920\u7528\u4e86\u3002<\/p>\n\n\n\n<p>\u7136\u800c\u5728\u5be6\u4f5c\u4e0a\uff0c\u7531\u65bc\u4e0d\u662f\u6240\u6709\u7684 CPU \u90fd\u80fd\u5920\u5f88\u6709\u6548\u7387\u5730\u8655\u7406\u55ae\u4e00 bit \u7684\u904b\u7b97\uff0c\u56e0\u6b64\u901a\u5e38\u7de8\u8b6f\u5668\u6703\u7528\u5176\u4ed6\u66f4\u6709\u6548\u7387\u65b9\u5f0f\u7684\u8655\u7406\u3002<\/p>\n\n\n\n<p>C++ \u8a9e\u8a00\u6a19\u6e96\u4e26\u6c92\u6709\u786c\u6027\u898f\u5b9a <code>bool<\/code> \u8981\u7528\u591a\u5927\u7684\u8a18\u61b6\u9ad4\u7a7a\u9593\u5be6\u4f5c\uff0c\u628a\u9019\u4ef6\u4e8b\u7559\u7d66\u7de8\u8b6f\u5668\u81ea\u884c\u6c7a\u5b9a\u3002\u4ee5 Visual C++ \u4f86\u8aaa\uff0cVisual C++ 4.2 \u662f\u5229\u7528 <code>typedef<\/code> \u5c07 <code>bool<\/code> \u5b9a\u7fa9\u6210 <code>int<\/code>\uff0c\u56e0\u6b64 1 \u500b <code>bool<\/code> \u8b8a\u6578\u6703\u5360\u7528 4 \u500b byte \u7684\u7a7a\u9593\uff1b\u4f46\u5728 Visual C++ 5.0 \u4ee5\u5f8c\u7684\u7248\u672c\uff0c<code>bool<\/code> \u5247\u5be6\u4f5c\u70ba\u5360\u7528 1 \u500b byte \u7684\u5167\u5efa\u578b\u5225\u3002\u5728\u76ee\u524d x86 \u7248\u7684 GCC \u4e2d\uff0c<code>bool<\/code> \u5360\u7528\u7684\u7a7a\u9593\u4e5f\u662f 1 \u500b byte\uff1b\u4f46\u4f9d\u64da CPU \u67b6\u69cb\u7684\u4e0d\u540c\uff0c\u53ef\u80fd\u6703\u6709\u4e0d\u540c\u7684\u505a\u6cd5\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u60f3\u8981\u6e2c\u8a66\u7cfb\u7d71\/\u7de8\u8b6f\u5668\u5982\u4f55\u5be6\u4f5c\uff0c\u53ef\u4ee5\u8a66\u8457\u7de8\u8b6f\u4e26\u57f7\u884c\u4e0b\u9762\u9019\u500b\u5c0f\u7a0b\u5f0f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><pre><code class=\"language-cpp\">\n#include &lt;iostream&gt;\nusing namespace std;\nint main(void)\n{\n    cout &lt;&lt; Size of bool =  &lt;&lt; sizeof(bool) &lt;&lt; endl;\n    return 0;\n}\n<\/code><\/pre>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u8cc7\u6599\u5c0d\u9f4a (Data Alignment)<\/h2>\n\n\n\n<p>\u9996\u5148\u6211\u5011\u5148\u4f86\u770b\u4e00\u500b\u5c0f\u7a0b\u5f0f\uff1a\uff08\u4ee5\u4e0b\u7a0b\u5f0f\u5747\u5728 x86-64 \u7248\u7684 Ubuntu Linux \u4e0a\uff0c\u4f7f\u7528 GCC \u7de8\u8b6f\u57f7\u884c\uff09<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-cpp\">\n\/\/ File: data_align_1.C\n#include &lt;iostream&gt;\nusing namespace std;\n\nstruct STRUCT_A {\n    bool b;\n    int  i;\n};\n\nint main(void)\n{\n    STRUCT_A myVar;\n    cout &lt;&lt; Size of myVar.b =  &lt;&lt; sizeof(myVar.b) &lt;&lt; endl;\n    cout &lt;&lt; Size of myVar.i =  &lt;&lt; sizeof(myVar.i) &lt;&lt; endl;\n    cout &lt;&lt; Size of myVar   =  &lt;&lt; sizeof(myVar) &lt;&lt; endl;\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u7de8\u8b6f\u8207\u57f7\u884c\u7d50\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-shell-session\">\n$ g++ data_align_1.C\n$ .\/a.out\nSize of myVar.b = 1\nSize of myVar.i = 4\nSize of myVar   = 8<\/code><\/pre>\n\n\n\n<p>\u300c\u7b49\u4e00\u4e0b\uff01\u660e\u660e <code>STRUCT_A<\/code> \u4e2d\u7684\u5169\u500b\u8cc7\u6599\u6210\u54e1 <code>b<\/code> \u548c <code>i<\/code> \u7684\u9ad4\u7a4d\u5206\u5225\u662f 1 \u548c 4 \u500b bytes\uff0c\u70ba\u4ec0\u9ebc\u5408\u8d77\u4f86\u8b8a\u6210 <code>STRUCT_A<\/code> \u4e4b\u5f8c\uff0c\u5c31\u8b8a\u6210 8 \u500b bytes \u4e86\u5462\uff1f\u300d \u662f\u554a\uff01\u70ba\u4ec0\u9ebc\u5462\uff1f\u6211\u5011\u4f86\u628a <code>myVar.b<\/code> \u548c <code>myVar.i<\/code> \u7684\u8a18\u61b6\u9ad4\u4f4d\u5740\u5370\u51fa\u4f86\u770b\u770b\u597d\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-\">\n\/\/ File: data_align_2.C\n#include &lt;iostream&gt;\nusing namespace std;\n\nstruct STRUCT_A {\n   bool b;\n   int  i;\n};\n\nint main(void)\n{\n   STRUCT_A myVar;\n\n   cout &lt;&lt; Size of myVar.b =  &lt;&lt; sizeof(myVar.b) &lt;&lt; endl;\n   cout &lt;&lt; Size of myVar.i =  &lt;&lt; sizeof(myVar.i) &lt;&lt; endl;\n   cout &lt;&lt; Size of myVar   =  &lt;&lt; sizeof(myVar) &lt;&lt; endl;\n\n   \/\/ \u5370\u51fa myVar \u4e2d\u6240\u6709\u6210\u54e1\u7684\u8a18\u61b6\u9ad4\u4f4d\u5740\n   cout &lt;&lt; endl;\n   cout &lt;&lt; Addr of myVar.b =  &lt;&lt; &amp;myVar.b &lt;&lt; endl;\n   cout &lt;&lt; Addr of myVar.i =  &lt;&lt; &amp;myVar.i &lt;&lt; endl;\n   return 0;\n}\n<\/code><\/pre>\n\n\n\n<p>\u57f7\u884c\u7d50\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-shell-session\">\n$ .\/a.out\nSize of myVar.b = 1\nSize of myVar.i = 4\nSize of myVar   = 8\nAddr of myVar.b = 0x7fff41fe3e00\nAddr of myVar.i = 0x7fff41fe3e04\n<\/code><\/pre>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u8a66\u8457\u591a\u8dd1\u5e7e\u6b21\uff0c\u96d6\u7136\u6bcf\u6b21\u8dd1\u51fa\u4f86\u7684\u8a18\u61b6\u9ad4\u4f4d\u5740\u53ef\u80fd\u4e0d\u4e00\u6a23\uff0c\u4f46\u90fd\u6703\u7b26\u5408\u5169\u4ef6\u4e8b\u5be6\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li> <code>myVar.i<\/code> \u7684\u4f4d\u5740\u4e00\u5b9a\u662f 4 \u7684\u500d\u6578\uff0c\u800c\u4e14 <code>myVar<\/code> \u7684\u4f4d\u5740\uff08\u4e5f\u5c31\u662f <code>myVar.b<\/code> \u7684\u4f4d\u5740\uff09\u4e5f\u662f 4 \u7684\u500d\u6578\u3002 <\/li><li> \u96d6\u7136 <code>myVar.b<\/code> \u7684\u9ad4\u7a4d\u53ea\u6709 1 byte\uff0c\u4f46 <code>myVar.i<\/code> \u7684\u4f4d\u5740\u537b\u662f\u5728\u300c<code>myVar.b<\/code> \u7684\u4f4d\u5740 + 4\u300d\uff0c\u800c\u975e\u300c<code>myVar.b<\/code> \u7684\u4f4d\u5740 + 1\u300d\u3002 <\/li><\/ol>\n\n\n\n<p>\u9019\u5176\u5be6\u662f\u4f5c\u696d\u7cfb\u7d71\u548c\u7de8\u8b6f\u5668\u5e6b\u4f60\u505a\u7684\u5b89\u6392\u3002\u90a3\u70ba\u4ec0\u9ebc\u5b83\u5011\u8981\u9019\u6a23\u505a\u5462\uff1f\u9019\u548c CPU \u7684\u7d50\u69cb\u8a2d\u8a08\u6709\u95dc\u4fc2\u3002<\/p>\n\n\n\n<p>\u73fe\u4ee3\u5927\u90e8\u4efd\u7684 CPU \u5728\u8b80\u53d6\u8a18\u61b6\u9ad4\u5167\u5bb9\u7684\u6642\u5019\uff0c\u4e26\u4e0d\u662f 1 \u500b byte 1 \u500b byte \u8b80\u53d6\u7684\uff0c\u800c\u662f\u4f9d\u7167\u5176\u8cc7\u6599\u7dda\u7684\u5bec\u5ea6\uff0c\u4e00\u6b21\u8b80\u53d6\u6578\u500b byte\uff08\u76ee\u524d\u4e00\u822c\u4f86\u8aaa\u662f 4 \u500b byte\uff0c\u4e5f\u5c31\u662f 32 \u500b bit\uff09\u7684\u8cc7\u6599\u3002\u800c\u4e14\u901a\u5e38\u8b80\u53d6\u4f4d\u5740\u7684\u8d77\u59cb\u4f4d\u7f6e\u4e5f\u6709\u9650\u5236\uff0c\u4f8b\u5982\u4e00\u6b21\u8981\u8b80 4 \u500b byte\uff0c\u90a3\u9ebc\u958b\u59cb\u7684\u4f4d\u5740\u5c31\u5fc5\u9808\u662f 4 \u7684\u500d\u6578\u3002\u9019\u500b\u55ae\u4f4d\u6211\u5011\u4e00\u822c\u7a31\u70ba <strong>chunk<\/strong>\u3002<\/p>\n\n\n\n<p>\u5047\u8a2d\u6211\u5011\u6709\u500b\u9019\u6a23\u7684\u7d44\u8a9e\u6307\u4ee4\uff1a\uff08\u4e0b\u9762\u7684\u7d44\u8a9e\u662f\u53c3\u8003 GNU Assembler \u7684\u8a9e\u6cd5\u7de8\u51fa\u4f86\u7684\uff0c\u5be6\u969b CPU \u53ef\u80fd\u6c92\u6709 MOVL \u9019\u6a23\u7684\u6307\u4ee4\uff0c\u50c5\u4f9b\u53c3\u8003\uff09<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-\">\n# \u5f9e\u7d55\u5c0d\u4f4d\u5740 0x98760003 \u958b\u59cb\uff0c\u642c 4 \u500b byte \u7684\u8cc7\u6599\u5230 R9 \u66ab\u5b58\u5668\nMOVL         $0x98760003, %r8\nMOVL         (%r8), %r9<\/code><\/pre>\n\n\n\n<p>\u5728\u5927\u90e8\u4efd RISC \u7cfb\u5217\u7684 CPU\uff08\u5982 ARM\u3001PowerPC \u7b49\uff09\u4e0a\u4e26\u4e0d\u652f\u63f4\u300c\u8de8 chunk\u300d\u5b58\u53d6\u8a18\u61b6\u9ad4\u3002\u82e5\u662f\u4f60\u8981\u6c42 CPU \u57f7\u884c\u4e0a\u9762\u7684\u6307\u4ee4\u7684\u8a71\uff0cCPU \u53ef\u80fd\u6703\u56e0\u70ba\u7121\u6cd5\u57f7\u884c\u800c\u7522\u751f\u4f8b\u5916\u72c0\u6cc1 (exception)\u3002\u81f3\u65bc x86 \u7cfb\u5217\u7684 CPU\uff0c\u96d6\u7136\u53ef\u4ee5\u57f7\u884c\uff0c\u4f46\u4e00\u822c\u4f86\u8aaa\u57f7\u884c\u6548\u7387\u6703\u6bd4\u8f03\u5dee\u3002<\/p>\n\n\n\n<p>\u5728\u4e0d\u652f\u63f4\u300c\u8de8 chunk \u5b58\u53d6\u8a18\u61b6\u9ad4\u300d\u7684 CPU \u4e0a\uff0c\u82e5\u662f\u786c\u8981\u505a\u7684\u8a71\uff0c\u5fc5\u9808\u8981\u8b80\u53d6\u524d\u5f8c\u7684 2 \u500b chunk \u7684\u5167\u5bb9\uff0c\u7136\u5f8c\u518d\u6e4a\u6210\u6211\u5011\u60f3\u8981\u7684\u7d50\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-\">\n# \u5148\u5c07 0x98760000 \u9019\u500b chunk \u642c\u9032\u4f86\uff0c\u53d6\u51fa 0x98760003 \u958b\u59cb\u7684 1 \u500b byte\u3002\n# \u5047\u8a2d\u9019\u9846 CPU \u70ba little-endian\uff0c\u5247\u6b64 byte \u70ba\u6700\u4f4e\u7684\u90a3\u500b byte\u3002\nMOVL         $0x98760000, %r8\nMOVL         (%r8), %r10\nANDL         $0x000000FF, %r10  # \u7559\u4e0b\u6700\u5f8c\u7684 1 \u500b byte\n\n# \u7136\u5f8c\u518d\u8b80\u9032 0x98760004 \u90a3\u500b chunk\uff0c\u53d6\u51fa 0x98760004~0x98760006 \u9019 3 \u500b\n# byte\uff0c\u5f80\u9ad8\u4f4d\u5143 shift 8 \u500b bit\u3002\nMOVL         $0x98760004, %r8\nMOVL         (%r8), %r9\nSALL         $0x08, %r9         # R9 \u5f80\u5de6 shift 8 bits\n\n# \u6700\u5f8c\u518d\u628a\u5169\u6b21\u53d6\u5f97\u7684\u7d50\u679c\u7d44\u5408\u6210\u6211\u5011\u60f3\u8981\u7684\u5167\u5bb9\nORL          %r9, %r10<\/code><\/pre>\n\n\n\n<p>\u539f\u672c\u53ea\u9700\u8981\u5b58\u53d6\u8a18\u61b6\u9ad4 1 \u6b21\uff0c\u73fe\u5728\u5fc5\u9808\u8981\u5b58\u53d6 2 \u6b21\uff0c\u9084\u9700\u8981\u52a0\u4e0a\u984d\u5916\u7684\u904b\u7b97\uff0c\u53ef\u60f3\u800c\u77e5\u7684\u662f\u901f\u5ea6\u4e00\u5b9a\u6703\u8b8a\u6162\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u70ba\u4e86\u514b\u670d\u9019\u500b\u554f\u984c\uff0c\u4f5c\u696d\u7cfb\u7d71\u5728\u914d\u7f6e\u8a18\u61b6\u9ad4\u7684\u6642\u5019\u6703\u4ee5 chunk \u70ba\u55ae\u4f4d\uff1b\u800c\u7de8\u8b6f\u5668\u5728\u5b89\u6392\u8cc7\u6599\u7d50\u69cb\u6642\uff0c\u4e5f\u6703\u907f\u514d\u7522\u751f\u5fc5\u9808\u8de8 chunk \u5b58\u53d6\u7684\u72c0\u6cc1\u3002\u6211\u5011\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c<code>myVar.i<\/code> \u88ab\u5b89\u6392\u5728 <code>0x7fff41fe3e04<\/code> \u800c\u4e0d\u662f <code>0x7fff41fe3e01<\/code>\uff0c\u5c31\u662f\u9019\u500b\u539f\u56e0\u3002\u9019\u6a23\u7684\u884c\u70ba\uff0c\u6211\u5011\u5c31\u7a31\u4e4b\u70ba<strong>\u8cc7\u6599\u5c0d\u9f4a (Data Alignment)<\/strong>\u3002<\/p>\n\n\n\n<p>\u300c\u7de8\u8b6f\u5668\u4e00\u5b9a\u8981\u9019\u9ebc\u96de\u5a46\u55ce\uff1f\u6211\u5c31\u662f\u4e0d\u60f3\u8981\u6d6a\u8cbb\u8a18\u61b6\u9ad4\u7a7a\u9593\uff0c\u5c31\u7b97\u57f7\u884c\u7684\u901f\u5ea6\u518d\u6162\u4e5f\u6c92\u6709\u95dc\u4fc2\uff01\u300d \u5982\u679c\u4f60\u771f\u7684\u6709\u9700\u8981\u7684\u8a71\uff0c\u6c92\u554f\u984c\u3002\u4e00\u822c\u6709\u505a\u8cc7\u6599\u5c0d\u9f4a\u7684\u7de8\u8b6f\u5668\u90fd\u6703\u63d0\u4f9b\u95dc\u6389\u9019\u500b\u529f\u80fd\u7684\u505a\u6cd5\u3002\u4ee5 Visual C++ \u548c GCC \u4f86\u8aaa\uff0c\u4f60\u53ef\u4ee5\u5728\u300c\u4e0d\u60f3\u505a\u8cc7\u6599\u5c0d\u9f4a\u300d\u7684\u8cc7\u6599\u7d50\u69cb\u524d\u5f8c\u52a0\u4e0a\u5169\u884c <code>#pragma<\/code> \u6307\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-cpp\">\n\/\/ File: data_align_3.C\n#include &lt;iostream&gt;\n\nusing namespace std;\n\n#pragma pack(push,1)   \/* \u52a0\u5165\u9019\u4e00\u884c *\/\nstruct STRUCT_A {\n    bool b;\n    int  i;\n};\n#pragma pack(pop)  \/* \u9084\u6709\u9019\u4e00\u884c *\/\n\nint main(void)\n{\n    STRUCT_A myVar;\n    cout &lt;&lt; Size of myVar.b =  &lt;&lt; sizeof(myVar.b) &lt;&lt; endl;\n    cout &lt;&lt; Size of myVar.i =  &lt;&lt; sizeof(myVar.i) &lt;&lt; endl;\n    cout &lt;&lt; Size of myVar   =  &lt;&lt; sizeof(myVar) &lt;&lt; endl;\n\n    \/\/ \u5370\u51fa myVar \u4e2d\u6240\u6709\u6210\u54e1\u7684\u8a18\u61b6\u9ad4\u4f4d\u7f6e\n    cout &lt;&lt; endl;\n    cout &lt;&lt; Addr of myVar.b =  &lt;&lt; &amp;myVar.b &lt;&lt; endl;\n    cout &lt;&lt; Addr of myVar.i =  &lt;&lt; &amp;myVar.i &lt;&lt; endl;\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\uff08\u6bcf\u4e00\u5957\u7de8\u8b6f\u5668\u7684\u505a\u6cd5\u53ef\u80fd\u4e0d\u592a\u4e00\u6a23\uff0c\u4e0d\u904e Visual C++ \u548c GCC \u5728\u9019\u4ef6\u4e8b\u60c5\u4e0a\u525b\u597d\u6709\u5171\u8b58\u3002\uff09<\/p>\n\n\n\n<p>\u8f38\u51fa\u7684\u7d50\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-shell-session\">\n$ .\/a.out\nSize of myVar.b = 1\nSize of myVar.i = 4\nSize of myVar   = 5\nAddr of myVar.b = 0x7fff41fe3e00\nAddr of myVar.i = 0x7fff41fe3e01<\/code><\/pre>\n\n\n\n<p>\u55ef\uff0c\u770b\u6a23\u5b50 <code>myVar.i<\/code> \u7684\u78ba\u4e56\u4e56\u5730\u8cbc\u5728 <code>myVar.b<\/code> \u5f8c\u9762\u4e86\u3002\u5f88\u597d\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5ef6\u4f38\u601d\u8003<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li> \u300c\u5f37\u5236\u95dc\u9589\u8cc7\u6599\u5c0d\u9f4a\u529f\u80fd\u300d\u6240\u7522\u751f\u51fa\u4f86\u7684\u8cc7\u6599\u7d50\u69cb\uff0c\u548c\u4e00\u822c\u60c5\u6cc1\uff08\u958b\u555f\u8cc7\u6599\u5c0d\u9f4a\uff09\u6240\u7522\u751f\u51fa\u4f86\u7684\u8cc7\u6599\u7d50\u69cb\uff0c\u7de8\u8b6f\u5668\u6703\u7522\u751f\u51fa\u4e0d\u540c\u7684\u6a5f\u68b0\u8a9e\u8a00\u4f86\u8655\u7406\u55ce\uff1f\u6211\u5011\u53ef\u4ee5\u8981\u6c42\u7de8\u8b6f\u5668\u7522\u751f\u7d44\u8a9e\u7a0b\u5f0f\uff0c\u7136\u5f8c\u518d\u89c0\u5bdf\u7d44\u8a9e\u7a0b\u5f0f\u7684\u5167\u5bb9\uff1b\u6216\u8005\u53ef\u4ee5\u76f4\u63a5\u5f9e\u9664\u932f\u5668\u7684\u53cd\u7d44\u8b6f\u8996\u7a97\u89c0\u5bdf\u3002 <\/li><li> 8 \u4f4d\u5143\u7684 CPU\uff08\u4f8b\u5982 8051\uff09\u3001\u7de8\u8b6f\u5668\uff08\u4f8b\u5982 Keil C51\uff09\u6703\u505a\u8cc7\u6599\u5c0d\u9f4a\u55ce\uff1f <\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u53c3\u8003\u8cc7\u6599<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/zh.wikipedia.org\/wiki\/%E5%B8%83%E6%9E%97%E5%80%BC\">\u5e03\u6797<\/a> (Wikipedia)<\/li><li><a href=\"http:\/\/stackoverflow.com\/questions\/4897844\/is-sizeofbool-defined\">Is sizeof(bool) defined?<\/a> (StackOverflow)<\/li><li><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/tf4dy80a.aspx\">bool (C++)<\/a> (MSDN)<\/li><li><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa290049(v=vs.71).aspx\">Windows Data Alignment on IPF, x86, and x64<\/a> (MSDN)<\/li><li><a href=\"http:\/\/lemire.me\/blog\/archives\/2012\/05\/31\/data-alignment-for-speed-myth-or-reality\/\">Data alignment for speed: myth or reality?<\/a> by Daniel Lemire<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u9019\u7bc7\u6587\u7ae0\u7684\u5167\u5bb9\uff0c\u7de3\u8d77\u65bc\u300c\u7a0b\u5f0f\u4eba\u96dc\u8a8c\u300d\u8a0e\u8ad6\u5340\u7684\u9019\u500b\u8a0e\u8ad6\u4e32\u3002\u9019\u500b\u8a0e\u8ad6\u4e32\u5230\u6700\u5f8c\u5df2\u7d93\u5931\u7126\u4e86\uff0c\u4e0d\u904e\u6709\u5e7e\u500b\u91cd\u9ede\u662f\u503c\u5f97 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13],"tags":[23,26,59],"table_tags":[],"class_list":["post-184","post","type-post","status-publish","format-standard","hentry","category--computer-science","tag-c-2","tag-data-alignment","tag-59"],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184"}],"version-history":[{"count":4,"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":585,"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions\/585"}],"wp:attachment":[{"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/blog.cclo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftable_tags&post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}