{"id":158,"date":"2021-10-31T01:41:22","date_gmt":"2021-10-30T17:41:22","guid":{"rendered":"http:\/\/139.224.63.49\/?p=158"},"modified":"2021-10-31T01:41:22","modified_gmt":"2021-10-30T17:41:22","slug":"c%e8%af%ad%e8%a8%80%e4%b8%ad%e5%af%b9%e4%ba%8e%e7%a9%ba%e5%87%bd%e6%95%b0%e5%88%97%e8%a1%a8%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/iamnear.top\/?p=158","title":{"rendered":"c\u8bed\u8a00\u4e2d\u5bf9\u4e8e\u7a7a\u51fd\u6570\u5217\u8868\u7684\u95ee\u9898"},"content":{"rendered":"\n<p>\u770b\u4e0b\u9762\u8fd9\u6bb5\u7a0b\u5e8f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\nint f1()\n{\n    return 0;\n}\nint f2(void)\n{\n    return 0;\n}\nint main()\n{\n    f1(3.);\n    \/\/f2(3.);\/\/\u5982\u679c\u53bb\u6389\u8fd9\u4e00\u884c\u7684\u6ce8\u91ca\uff0c\u7f16\u8bd1\u4f1a\u62a5\u9519 error: too many arguments to function \u2018f2\u2019\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u5bf9\u4e8ef2\uff0c\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0cvoid\u5c31\u8bf4\u660e\u4e0d\u80fd\u6709\u53c2\u6570\uff0c\u5f3a\u884c\u7ed9\u53c2\u6570\u8c03\u7528\u80af\u5b9a\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\u5bf9\u4e8ef1\uff0c\u5c45\u7136\u53ef\u4ee5\u52a0\u53c2\u6570\u8c03\u7528\uff1f<\/p>\n\n\n\n<p>\u5728gcc\u4e0b\u4f3c\u4e4e\u6ca1\u6709\u62a5\u9519\u63d0\u793a\uff0c\u5728clang\u4f1a\u62a5warning\u3002<\/p>\n\n\n\n<p>gcc\u4e0b\u5982\u679c\u52a0-Wstrict-prototypes\u7684\u8bdd\uff0c\u4e5f\u4f1a\u62a5warning<\/p>\n\n\n\n<p>\u5173\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u5728\u7f51\u4e0a\u641c\uff0cstackoverflow\u4e0a\u9762\u6709\u4e00\u4e9b\u5f88\u597d\u7684\u56de\u7b54<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/12643202\/why-does-gcc-allow-arguments-to-be-passed-to-a-function-defined-to-be-with-no-ar\">https:\/\/stackoverflow.com\/questions\/12643202\/why-does-gcc-allow-arguments-to-be-passed-to-a-function-defined-to-be-with-no-ar<\/a><\/p>\n\n\n\n<p>\u5728c99\u7684\u6807\u51c6\u4e2d\uff0c\u6709\u8fd9\u6837\u4e00\u6bb5\u8bdd\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p><\/p><cite>An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters.<\/cite><\/blockquote><\/figure>\n\n\n\n<p>c99\u6807\u51c6\u6587\u6863\u89c1<a href=\" http:\/\/www.open-std.org\/JTC1\/SC22\/WG14\/www\/docs\/n1256.pdf\"> http:\/\/www.open-std.org\/JTC1\/SC22\/WG14\/www\/docs\/n1256.pdf<\/a><\/p>\n\n\n\n<p>\u56e0\u6b64\u4ece\u6807\u51c6\u4e0a\u6765\u770b\uff0c\u8fd9\u4e2a\u64cd\u4f5c\u662f\u672a\u5b9a\u4e49\u7684\u3002\u53ea\u4e0d\u8fc7\u76ee\u524d\u5927\u591a\u6570\u7f16\u8bd1\u5668\uff08gcc,clang,\u5176\u4ed6\u7684\u6211\u6ca1\u6d4b\u8bd5\u8fc7\uff09\u4e3a\u4e86\u4fdd\u8bc1\u5bf9\u65e7\u4ee3\u7801\u7684\u517c\u5bb9\u6027\uff0c\u4f1a\u5141\u8bb8\u8fd9\u4e2a\u7279\u6027\u3002<\/p>\n\n\n\n<p>\u8fd8\u6709\u4ee5\u4e0b\u51e0\u4e2a\u76f8\u5173\u95ee\u9898\u91cc\u9762\u7684\u56de\u7b54\u4e5f\u5f88\u597d\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/693788\/is-it-better-to-use-c-void-arguments-void-foovoid-or-not-void-foo\/36292431#36292431\">https:\/\/stackoverflow.com\/questions\/693788\/is-it-better-to-use-c-void-arguments-void-foovoid-or-not-void-foo\/36292431#36292431<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/51032\/is-there-a-difference-between-foovoid-and-foo-in-c-or-c\">https:\/\/stackoverflow.com\/questions\/51032\/is-there-a-difference-between-foovoid-and-foo-in-c-or-c<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/693788\/is-it-better-to-use-c-void-arguments-void-foovoid-or-not-void-foo\">https:\/\/stackoverflow.com\/questions\/693788\/is-it-better-to-use-c-void-arguments-void-foovoid-or-not-void-foo<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u770b\u4e0b\u9762\u8fd9\u6bb5\u7a0b\u5e8f\uff1a \u5bf9\u4e8ef2\uff0c\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0cvoid\u5c31\u8bf4\u660e\u4e0d\u80fd\u6709\u53c2\u6570\uff0c\u5f3a\u884c\u7ed9\u53c2\u6570\u8c03\u7528\u80af\u5b9a\u4f1a\u62a5\u9519\u3002 \u4f46\u662f&hellip; <a href=\"http:\/\/iamnear.top\/?p=158\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">c\u8bed\u8a00\u4e2d\u5bf9\u4e8e\u7a7a\u51fd\u6570\u5217\u8868\u7684\u95ee\u9898<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":{"0":"post-158","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-c_plus_plus","7":"h-entry","9":"h-as-article"},"_links":{"self":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158"}],"version-history":[{"count":1,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":159,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions\/159"}],"wp:attachment":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}