{"id":344,"date":"2023-02-22T02:45:24","date_gmt":"2023-02-22T10:45:24","guid":{"rendered":"http:\/\/bitas.net.cn\/?page_id=344"},"modified":"2023-02-22T03:11:01","modified_gmt":"2023-02-22T11:11:01","slug":"156-2","status":"publish","type":"page","link":"http:\/\/bitas.net.cn\/index.php\/sourcecode\/156-2\/","title":{"rendered":"156 \u7528 GDB \u8c03\u8bd5\u7a0b\u5e8f"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">add.h<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#ifndef LTTC_ADD_H_\n#define LTTC_ADD_H_\n\nextern int addend;\nextern int add(int *pz);\n\n#endif<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">add.c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include \"add.h\"\n\nint add(int *pz)\n{\n    if (pz) {\n        pz += addend;  \/\/ fixed: use '*pz` instead\n        return 0;\n    }   \n    else \n        return -1; \n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">zr.c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;assert.h>\n#include &lt;unistd.h>\n#include \"add.h\"\n\nint addend = 1;  \/\/ defintion\n\nint main(int argc, char *argv&#91;])\n{\n    int zr = 0, res;\n\n    printf(\"argc=%d\\n\", argc);\n    if (argc > 1)\n        printf(\"1st parameter is %s\\n\",\n            argv&#91;1]);\n\n    res = add(&amp;zr);\n    pause();\n    assert(res == 0); \n    assert(zr == 1); \n\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>add.h add.c zr.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-344","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/344","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=344"}],"version-history":[{"count":2,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/344\/revisions"}],"predecessor-version":[{"id":379,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/344\/revisions\/379"}],"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=344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}