简体   繁体   English

VS Code '无法打开源文件 "stdio.h" C/C++'

[英]VS Code 'cannot open source file "stdio.h" C/C++'

In the below image attached, I am getting error as cannot open source file "header file name" for both C as well as C++ headers.在下图中,我收到错误,因为无法打开 C 和 C++ 头文件的源文件“头文件名”。

https://i.stack.imgur.com/khIyN.png

How to fix this error for all the files.如何为所有文件修复此错误。

I have same problem.我有同样的问题。 There are a lot of solutions on the internet.互联网上有很多解决方案。 But I could not use any of them... I downloaded a visual studio solution in the internet but I could not built it.但我不能使用它们中的任何一个......我在互联网上下载了一个视觉工作室解决方案,但我无法构建它。 I got the error of "Can not open source file..." for all C/C++ library.对于所有 C/C++ 库,我收到“无法打开源文件...”的错误。 The solution was really simple.解决方案非常简单。

  1. Right click on the project under the solution.右键单击解决方案下的项目。
  2. Select properties (Alt+Enter) Select 属性(Alt+Enter)
  3. Under the "Configuration Properties" select "VC++ Directories"在“配置属性”select“VC++ 目录”下
  4. In the right panel select "include Directories"在右侧面板中 select “包括目录”
  5. At the end of its value add "$(includePath);"在其值的末尾添加“$(includePath);”
  6. Apply change and enjoy of bug fix:)应用更改并享受错误修复:)

This means that the vs code intellisense is looking at the header files wrong directory.这意味着 vs 代码智能感知正在查看头文件错误的目录。 You should see a bulb icon when you hover over the #include click it and you should see options regarding the location where it is looking for the headers.当您将鼠标悬停在#include时,您应该会看到一个灯泡图标,单击它,您应该会看到有关它正在寻找标题的位置的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM