{"id":21292,"date":"2024-11-19T16:01:50","date_gmt":"2024-11-19T08:01:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21292\/"},"modified":"2024-11-19T16:01:50","modified_gmt":"2024-11-19T08:01:50","slug":"vscode%e6%80%8e%e4%b9%88%e5%bc%95%e5%85%a5%e8%87%aa%e5%ae%9a%e4%b9%89%e5%a4%b4%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21292\/","title":{"rendered":"vscode\u600e\u4e48\u5f15\u5165\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6"},"content":{"rendered":"<blockquote><p>\n  \u5c06\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u5f15\u5165 vs code \u6709\u4e09\u79cd\u65b9\u6cd5\uff1a\u624b\u52a8\u66f4\u65b0 include \u8def\u5f84\u4f7f\u7528 cmake\uff08\u63a8\u8350\uff09\u4f7f\u7528 visual studio code \u63d2\u4ef6\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/15\/2024051506571984102.jpg\" class=\"aligncenter\" title=\"vscode\u600e\u4e48\u5f15\u5165\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u63d2\u56fe\" alt=\"vscode\u600e\u4e48\u5f15\u5165\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u5f15\u5165 Visual Studio Code (VS Code)<\/strong><\/p>\n<p>\u5c06\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u5f15\u5165 VS Code \u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p><strong>1. \u624b\u52a8\u66f4\u65b0 include \u8def\u5f84<\/strong><\/p>\n<ul>\n<li>\u6253\u5f00 VS Code \u7684\u201c\u8bbe\u7f6e\u201d\uff08Cmd\/Ctrl + ,\uff09\u3002<\/li>\n<li>\u641c\u7d22\u201cC\/C++: Include Path\u201d\u3002<\/li>\n<li>\u5728\u201cInclude Path\u201d\u8bbe\u7f6e\u4e0b\u7684\u201c\u503c\u201d\u5b57\u6bb5\u4e2d\uff0c\u6dfb\u52a0\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/li>\n<li>\u786e\u4fdd\u8def\u5f84\u4ee5\u5206\u53f7 (;) \u5206\u9694\u3002<\/li>\n<\/ul>\n<p><strong>2. \u4f7f\u7528 CMake\uff08\u63a8\u8350\uff09<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a CMakeLists.txt \u6587\u4ef6\u3002<\/li>\n<li>\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff0c\u5176\u4e2d &#8220;path\/to\/header&#8221; \u662f\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u7684\u8def\u5f84\uff1a<\/li>\n<\/ul>\n<pre>include_directories(path\/to\/header)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5728 VS Code \u4e2d\u6253\u5f00 CMakeLists.txt \u6587\u4ef6\u3002<\/li>\n<li>\u5355\u51fb\u201c\u6784\u5efa\u201d\u9009\u9879\u5361\uff0c\u7136\u540e\u5355\u51fb\u201c\u91cd\u65b0\u52a0\u8f7d CMake \u9879\u76ee\u201d\u3002<\/li>\n<\/ul>\n<p><strong>3. Visual Studio Code \u63d2\u4ef6<\/strong><\/p>\n<ul>\n<li>\u5b89\u88c5\u201cInclude Header in Source\u201d\u63d2\u4ef6\u3002<\/li>\n<li>\u5c06\u5149\u6807\u653e\u5728\u4ee3\u7801\u4e2d\u9700\u8981\u5934\u6587\u4ef6\u7684\u4f4d\u7f6e\u3002<\/li>\n<li>\u6309\u4e0b Cmd\/Ctrl + Shift + P\uff0c\u7136\u540e\u8f93\u5165\u201cInclude header\u201d\u3002<\/li>\n<li>\u4ece\u5217\u8868\u4e2d\u9009\u62e9\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u8981\u5c06\u540d\u4e3a\u201cmy_header.h\u201d\u7684\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u5f15\u5165\u4f4d\u4e8e\u201cpath\/to\/project\u201d\u6587\u4ef6\u5939\u4e2d\u7684\u9879\u76ee\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>\u624b\u52a8\u66f4\u65b0 include \u8def\u5f84\uff1a<\/strong><\/p>\n<ul>\n<li>\u8f6c\u5230 VS Code \u8bbe\u7f6e\u3002<\/li>\n<li>\u5728\u201cC\/C++: Include Path\u201d\u4e2d\u6dfb\u52a0\uff1a<\/li>\n<\/ul>\n<pre>path\/to\/project\/include;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528 CMake\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728 CMakeLists.txt \u6587\u4ef6\u4e2d\u6dfb\u52a0\uff1a<\/li>\n<\/ul>\n<pre>include_directories(path\/to\/project\/include)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u63d2\u4ef6\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u6253\u5f00\u201cmy_header.h\u201d\u6587\u4ef6\u3002<\/li>\n<li>\u5c06\u5149\u6807\u653e\u5728\u4ee3\u7801\u4e2d\u7684\u67d0\u4e2a\u4f4d\u7f6e\u3002<\/li>\n<li>\u6309\u4e0b Cmd\/Ctrl + Shift + P\u3002<\/li>\n<li>\u8f93\u5165\u201cInclude header\u201d\u3002<\/li>\n<li>\u9009\u62e9\u201cmy_header.h\u201d\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5f15\u5165\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u5f15\u5165 vs code \u6709\u4e09\u79cd\u65b9\u6cd5\uff1a\u624b\u52a8\u66f4\u65b0 include \u8def\u5f84\u4f7f\u7528 cmake\uff08\u63a8\u8350\uff09\u4f7f\u7528 visual studio code \u63d2\u4ef6 \u5982\u4f55\u5c06\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u5f15\u5165 Visual Studio Code (VS Code) \u5c06\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u5f15\u5165 VS Code \u7684\u65b9\u6cd5\u5982\u4e0b\uff1a 1. \u624b\u52a8\u66f4\u65b0 include \u8def\u5f84 \u6253\u5f00 VS Code \u7684\u201c\u8bbe\u7f6e\u201d\uff08Cmd\/Ctrl + ,\uff09\u3002 \u641c\u7d22\u201cC\/C++: Include Path\u201d\u3002 \u5728\u201cInclude Path\u201d\u8bbe\u7f6e\u4e0b\u7684\u201c\u503c\u201d\u5b57\u6bb5\u4e2d\uff0c\u6dfb\u52a0\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u7684\u8def\u5f84\u3002 \u786e\u4fdd\u8def\u5f84\u4ee5\u5206\u53f7 (;) \u5206\u9694\u3002 2. \u4f7f\u7528 CMake\uff08\u63a8\u8350\uff09 \u521b\u5efa\u4e00\u4e2a CMakeLists.txt \u6587\u4ef6\u3002 \u6dfb\u52a0\u4ee5\u4e0b\u884c\uff0c\u5176\u4e2d &#8220;path\/to\/header&#8221; \u662f\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6\u7684\u8def\u5f84\uff1a include_directories(path\/to\/header) \u767b\u5f55\u540e\u590d\u5236 \u5728 VS Code \u4e2d\u6253\u5f00 CMakeLists.txt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21292","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21292"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21292\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}