{"id":74555,"date":"2024-02-27T11:50:29","date_gmt":"2024-02-27T03:50:29","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=74555"},"modified":"2024-02-27T11:50:43","modified_gmt":"2024-02-27T03:50:43","slug":"c%e8%af%ad%e8%a8%80%e5%8f%af%e4%bb%a5%e6%b3%9b%e5%9e%8b%e7%bc%96%e7%a8%8b%e5%90%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/74555.html","title":{"rendered":"c\u8bed\u8a00\u53ef\u4ee5\u6cdb\u578b\u7f16\u7a0b\u5417"},"content":{"rendered":"<p style=\"text-align:center;\" ><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-74556\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/02\/img-S1wJPbihXhtAg1x5O6saIcrT.png?x-oss-process=image\/auto-orient,1\/format,webp\" width=\"600\" height=\"342\" alt=\"c\u8bed\u8a00\u53ef\u4ee5\u6cdb\u578b\u7f16\u7a0b\u5417\" \/><\/p>\n<p><strong>C\u8bed\u8a00\u53ef\u4ee5\u901a\u8fc7\u67d0\u4e9b\u6280\u5de7\u5b9e\u73b0\u7c7b\u4f3c\u6cdb\u578b\u7f16\u7a0b\u7684\u6548\u679c\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u4f7f\u7528\u5b8f\u5b9a\u4e49\u6cdb\u578b\u4ee3\u7801\u3001\u8f85\u52a9\u4ee5\u51fd\u6570\u6307\u9488\u5b9e\u73b0\u6cdb\u578b\u63a5\u53e3\u3001\u4ee5\u53ca\u901a\u8fc7\u65e0\u7c7b\u578b\u6307\u9488\uff08void*\uff09\u642d\u914d\u6307\u5b9a\u7c7b\u578b\u7684\u64cd\u4f5c\u6765\u6a21\u62df\u6cdb\u578b\u3002<\/strong> \u5728\u5c55\u5f00\u63cf\u8ff0\u4e4b\u524d\uff0c\u6211\u4eec\u5fc5\u987b\u6e05\u695a\uff0cC\u8bed\u8a00\u672c\u8eab\u5e76\u4e0d\u76f4\u63a5\u652f\u6301\u73b0\u4ee3\u6cdb\u578b\u7f16\u7a0b\u7684\u7279\u6027\uff0c\u5982C++\u6a21\u677f\u6216C#\u7684\u6cdb\u578b\u3002C\u8bed\u8a00\u662f\u57281972\u5e74\u8bbe\u8ba1\u7684\uff0c\u90a3\u65f6\u5019\u6cdb\u578b\u7f16\u7a0b\u6982\u5ff5\u8fd8\u6ca1\u666e\u53ca\u3002\u4e0d\u8fc7\uff0cC\u8bed\u8a00\u56e0\u5176\u7075\u6d3b\u548c\u63a5\u8fd1\u786c\u4ef6\u7684\u7279\u6027\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u901a\u8fc7\u5404\u79cd\u6280\u5de7\u95f4\u63a5\u5b9e\u73b0\u7c7b\u4f3c\u6cdb\u578b\u7684\u529f\u80fd\u3002<\/p>\n<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u8ba8\u8bbaC\u8bed\u8a00\u662f\u5426\u53ef\u4ee5\u8fdb\u884c\u6cdb\u578b\u7f16\u7a0b\uff0c\u4ee5\u53ca\u5982\u4f55\u5728C\u8bed\u8a00\u4e2d\u4f7f\u7528\u5404\u79cd\u6280\u5de7\u6765\u6a21\u62df\u6cdb\u578b\uff1a<\/p>\n<h2><strong>\u4e00\u3001\u4f7f\u7528\u5b8f\u5b9a\u4e49\u8fdb\u884c\u6cdb\u578b\u7f16\u7a0b<\/strong><\/h2>\n<p>\u5b8f\u5b9a\u4e49\uff08#define\uff09\u662fC\u8bed\u8a00\u4e2d\u4e00\u79cd\u5f3a\u5927\u7684\u9884\u5904\u7406\u6307\u4ee4\uff0c\u5b83\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728\u7f16\u8bd1\u524d\u5bf9\u4ee3\u7801\u8fdb\u884c\u6587\u672c\u66ff\u6362\u3002\u5b8f\u53ef\u4ee5\u5e26\u6709\u53c2\u6570\uff0c\u56e0\u6b64\u53ef\u4ee5\u5229\u7528\u5b8f\u5b9a\u4e49\u6765\u7f16\u5199\u7c7b\u4f3c\u6cdb\u578b\u7684\u4ee3\u7801\u7ed3\u6784\u3002\u4e0b\u9762\u662f\u901a\u8fc7\u5b8f\u5b9a\u4e49\u521b\u5efa\u6cdb\u578b\u51fd\u6570\u7684\u4f8b\u5b50\u3002<\/p>\n<h2><strong>\u4e8c\u3001\u65e0\u7c7b\u578b\u6307\u9488\u4e0e\u6cdb\u578b<\/strong><\/h2>\n<p>\u65e0\u7c7b\u578b\u6307\u9488\uff08void*\uff09\u53ef\u4ee5\u6307\u5411\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\u7f16\u5199\u80fd\u591f\u5904\u7406\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u7684\u51fd\u6570\u548c\u6570\u636e\u7ed3\u6784\u3002\u901a\u8fc7\u7ed3\u5408\u6307\u9488\u7c7b\u578b\u8f6c\u6362\u548c\u989d\u5916\u7684\u7c7b\u578b\u4fe1\u606f\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u7c7b\u4f3c\u6cdb\u578b\u7684\u6548\u679c\u3002<\/p>\n<h2><strong>\u4e09\u3001\u51fd\u6570\u6307\u9488\u5b9e\u73b0\u6cdb\u578b\u63a5\u53e3<\/strong><\/h2>\n<p>\u51fd\u6570\u6307\u9488\u662f\u53e6\u4e00\u79cd\u5728C\u8bed\u8a00\u4e2d\u5b9e\u73b0\u6cdb\u578b\u7f16\u7a0b\u7684\u6280\u672f\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u51fd\u6570\u6307\u9488\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u5176\u4ed6\u51fd\u6570\uff0c\u4f7f\u5f97\u5b83\u4eec\u80fd\u591f\u63a5\u53d7\u4e0d\u540c\u7684\u884c\u4e3a\u7b56\u7565\uff0c\u800c\u8fd9\u4e9b\u7b56\u7565\u53ef\u4ee5\u5728\u8c03\u7528\u51fd\u6570\u65f6\u5b9e\u73b0\u7279\u5b9a\u7684\u7c7b\u578b\u5904\u7406\u3002<\/p>\n<h2><strong>\u56db\u3001\u7ed3\u6784\u4f53\u548c\u8054\u5408\u4f53\u5728\u6cdb\u578b\u7f16\u7a0b\u4e2d\u7684\u5e94\u7528<\/strong><\/h2>\n<p>\u4f7f\u7528\u7ed3\u6784\u4f53\u548c\u8054\u5408\u4f53\u53ef\u4ee5\u5b58\u50a8\u989d\u5916\u7684\u7c7b\u578b\u4fe1\u606f\u548c\u503c\uff0c\u4ece\u800c\u53ef\u4ee5\u521b\u5efa\u80fd\u591f\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u6570\u636e\u7684\u6cdb\u578b\u6570\u636e\u7ed3\u6784\u3002<\/p>\n<h2><strong>\u4e94\u3001\u7c7b\u578b\u5b89\u5168\u7684\u6cdb\u578b\u7f16\u7a0b\u9650\u5236<\/strong><\/h2>\n<p>\u5c3d\u7ba1C\u8bed\u8a00\u63d0\u4f9b\u7684\u8fd9\u4e9b\u6280\u672f\u53ef\u4ee5\u6a21\u62df\u6cdb\u578b\u7f16\u7a0b\uff0c\u4f46\u5b83\u4eec\u65e0\u6cd5\u63d0\u4f9b\u50cfC++\u6a21\u677f\u6216C#\u6cdb\u578b\u90a3\u6837\u7684\u7c7b\u578b\u5b89\u5168\u4fdd\u8bc1\u3002\u4f7f\u7528\u8fd9\u4e9b\u6280\u5de7\u9700\u8981\u7a0b\u5e8f\u5458\u975e\u5e38\u6ce8\u610f\u7c7b\u578b\u8f6c\u6362\u548c\u6307\u9488\u7684\u4f7f\u7528\uff0c\u4ee5\u907f\u514d\u7c7b\u578b\u9519\u8bef\u548c\u5b89\u5168\u95ee\u9898\u3002<\/p>\n<h2><strong>\u516d\u3001C11\u7684\u6cdb\u578b\u9009\u62e9\u8868\u8fbe\u5f0f<\/strong><\/h2>\n<p>C11\u6807\u51c6\u5f15\u5165\u4e86_Generic\u5173\u952e\u5b57\uff0c\u5141\u8bb8\u521b\u5efa\u57fa\u4e8e\u7c7b\u578b\u7684\u9009\u62e9\u8868\u8fbe\u5f0f\uff0c\u8fd9\u662f\u5728C\u8bed\u8a00\u4e2d\u5b9e\u73b0\u6cdb\u578b\u64cd\u4f5c\u7684\u4e00\u79cd\u65b0\u65b9\u5f0f\u3002\u6211\u4eec\u5c06\u901a\u8fc7\u793a\u4f8b\u6765\u6df1\u5165\u63a2\u7a76\u5176\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u7684\u6280\u5de7\u548c\u7b56\u7565\uff0c\u53ef\u4ee5\u770b\u51fa\uff0cC\u8bed\u8a00\u80fd\u591f\u4ee5\u5176\u7279\u6709\u7684\u65b9\u5f0f\u8fdb\u884c\u4e00\u5b9a\u7a0b\u5ea6\u7684\u6cdb\u578b\u7f16\u7a0b\u3002\u7136\u800c\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u901a\u5e38\u6bd4\u73b0\u4ee3\u6cdb\u578b\u7f16\u7a0b\u66f4\u4e3a\u590d\u6742\uff0c\u5e76\u4e14\u7f3a\u4e4f\u7c7b\u578b\u5b89\u5168\u3002\u53ea\u6709\u6df1\u5165\u7406\u89e3C\u8bed\u8a00\uff0c\u5e76\u4e14\u8c28\u614e\u5730\u8fd0\u7528\u8fd9\u4e9b\u6280\u5de7\uff0c\u624d\u80fd\u5728\u4e0d\u727a\u7272\u5b89\u5168\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u7684\u524d\u63d0\u4e0b\uff0c\u5b9e\u73b0\u6cdb\u578b\u7f16\u7a0b\u7684\u76ee\u7684\u3002<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>C\u8bed\u8a00\u652f\u6301\u6cdb\u578b\u7f16\u7a0b\u5417\uff1f<\/strong><\/p>\n<p>\u6cdb\u578b\u7f16\u7a0b\u662f\u4e00\u79cd\u901a\u8fc7\u53c2\u6570\u5316\u7c7b\u578b\u6765\u5b9e\u73b0\u7684\u7f16\u7a0b\u8303\u5f0f\uff0cC\u8bed\u8a00\u672c\u8eab\u5e76\u4e0d\u76f4\u63a5\u652f\u6301\u6cdb\u578b\u7f16\u7a0b\uff0c\u6ca1\u6709\u7c7b\u4f3cC++\u7684\u6a21\u677f\u7279\u6027\u6216\u8005Java\u7684\u6cdb\u578b\u7c7b\u578b\u3002\u4e0d\u8fc7\uff0c\u6709\u4e00\u4e9b\u6280\u672f\u53ef\u4ee5\u5728C\u4e2d\u5b9e\u73b0\u7c7b\u4f3c\u6cdb\u578b\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u4f7f\u7528void\u6307\u9488\u6216\u8005\u5b8f\u6765\u5b9e\u73b0\u6cdb\u578b\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u3002\u4f7f\u7528void\u6307\u9488\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u8fdb\u884c\u64cd\u4f5c\uff0c\u4f46\u5728\u4f7f\u7528\u65f6\u9700\u8981\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff0c\u589e\u52a0\u4e86\u4ee3\u7801\u7684\u590d\u6742\u6027\u548c\u51fa\u9519\u7684\u53ef\u80fd\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728C\u8bed\u8a00\u4e2d\u5b9e\u73b0\u6cdb\u578b\u7f16\u7a0b\uff1f<\/strong><\/p>\n<p>\u5728C\u8bed\u8a00\u4e2d\u5b9e\u73b0\u6cdb\u578b\u7f16\u7a0b\u53ef\u4ee5\u4f7f\u7528void\u6307\u9488\u6216\u8005\u5b8f\u3002\u4f7f\u7528void\u6307\u9488\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u8fdb\u884c\u64cd\u4f5c\uff0c\u4f46\u9700\u8981\u5728\u8fd0\u884c\u65f6\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff0c\u53ef\u80fd\u4f1a\u9020\u6210\u7c7b\u578b\u5b89\u5168\u6027\u95ee\u9898\u3002\u800c\u4f7f\u7528\u5b8f\u5b9a\u4e49\u53ef\u4ee5\u5728\u9884\u5904\u7406\u9636\u6bb5\u5c06\u6cdb\u578b\u4ee3\u7801\u5c55\u5f00\u6210\u7279\u5b9a\u7c7b\u578b\u7684\u4ee3\u7801\uff0c\u907f\u514d\u4e86\u7c7b\u578b\u8f6c\u6362\u7684\u95ee\u9898\u3002\u4f46\u5b8f\u5b9a\u4e49\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4ee3\u7801\u53ef\u8bfb\u6027\u4e0b\u964d\u548c\u8c03\u8bd5\u56f0\u96be\u3002\u53e6\u5916\uff0c\u4e5f\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u51fd\u6570\u6307\u9488\u6216\u8005\u7ed3\u6784\u4f53\u6307\u9488\u7b49\u6280\u672f\u6765\u5b9e\u73b0\u6cdb\u578b\u7684\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u3002<\/p>\n<p><strong>C\u8bed\u8a00\u7684\u6cdb\u578b\u7f16\u7a0b\u6709\u54ea\u4e9b\u5c40\u9650\u6027\uff1f<\/strong><\/p>\n<p>\u5728C\u8bed\u8a00\u4e2d\u5b9e\u73b0\u6cdb\u578b\u7f16\u7a0b\u867d\u7136\u662f\u53ef\u884c\u7684\uff0c\u4f46\u4e5f\u5b58\u5728\u4e00\u4e9b\u5c40\u9650\u6027\u3002\u9996\u5148\uff0c\u4f7f\u7528void\u6307\u9488\u6216\u8005\u5b8f\u6765\u5b9e\u73b0\u6cdb\u578b\u4f1a\u589e\u52a0\u4ee3\u7801\u7684\u590d\u6742\u6027\uff0c\u964d\u4f4e\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002\u5176\u6b21\uff0c\u7c7b\u578b\u8f6c\u6362\u53ef\u80fd\u4f1a\u5f15\u5165\u7c7b\u578b\u9519\u8bef\uff0c\u5bfc\u81f4\u8fd0\u884c\u65f6\u9519\u8bef\u3002\u53e6\u5916\uff0cC\u8bed\u8a00\u672c\u8eab\u5e76\u6ca1\u6709\u63d0\u4f9b\u539f\u751f\u7684\u6cdb\u578b\u652f\u6301\uff0c\u5bfc\u81f4\u5b9e\u73b0\u6cdb\u578b\u529f\u80fd\u9700\u8981\u82b1\u8d39\u66f4\u591a\u7684\u5de5\u4f5c\u91cf\u3002\u56e0\u6b64\uff0c\u5728C\u8bed\u8a00\u4e2d\u8fdb\u884c\u6cdb\u578b\u7f16\u7a0b\u9700\u8981\u6743\u8861\u5229\u5f0a\uff0c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u9009\u62e9\u5408\u9002\u7684\u65b9\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"C\u8bed\u8a00\u53ef\u4ee5\u901a\u8fc7\u67d0\u4e9b\u6280\u5de7\u5b9e\u73b0\u7c7b\u4f3c\u6cdb\u578b\u7f16\u7a0b\u7684\u6548\u679c\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u4f7f\u7528\u5b8f\u5b9a\u4e49\u6cdb\u578b\u4ee3\u7801\u3001\u8f85\u52a9\u4ee5\u51fd\u6570\u6307\u9488\u5b9e\u73b0\u6cdb\u578b\u63a5\u53e3\u3001\u4ee5\u53ca [&hellip;]","protected":false},"author":1,"featured_media":74558,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/74555"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=74555"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/74555\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/74558"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=74555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=74555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=74555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}