简体   繁体   English

Visual Studio Code 不包含 C 头文件

[英]Visual Studio Code does not include C header files

I recently downloaded Visual Studio Code to begin learning the C programming language.我最近下载了 Visual Studio Code 开始学习 C 编程语言。 I installed the program as well as the C extension.我安装了该程序以及 C 扩展。 However, when I tried to create the "Hello, World!"但是,当我尝试创建“Hello, World!”时program, it would not run, and in the Problems menu it did not recognize the stdio.h header file, saying that I need to update my includePath.程序,它不会运行,并且在问题菜单中它无法识别 stdio.h 头文件,说我需要更新我的 includePath。 I have not been able to find any stdio.h file on my computer to link to.我无法在我的计算机上找到任何要链接的 stdio.h 文件。 Do I need to download the C library files (even though I have read they should be included with the compiler), and if so, where can I find them?我是否需要下载 C 库文件(即使我已经阅读它们应该包含在编译器中),如果需要,我在哪里可以找到它们? Or is there another solution?或者还有其他解决方案吗? Thanks, and sorry if this is a stupid question, I am new to this.谢谢,对不起,如果这是一个愚蠢的问题,我是新手。

I think you might be confusing VS Code with the VS IDE .我认为您可能会将VS CodeVS IDE混淆。

VS Code is a source editor only; VS Code 只是一个源代码编辑器; that is to say that it's basically just a glorified text editor.也就是说,它基本上只是一个美化的文本编辑器。 It has the ability to load extensions and open a shell to compile the code, and there are a few extensions that let you debug the code itself, but they can be tricky to get setup and installed to work well with C/C++ code.它能够加载扩展并打开一个 shell 来编译代码,并且有一些扩展可以让您调试代码本身,但是要设置和安装它们以与 C/C++ 代码一起工作可能会很棘手。 VS Code does not have a compiler/assembler/linker nor the requisite headers or SDK's as that is up to you (the user) to install and then point to those in your settings file. VS代码没有编译器/汇编器/连接器,也没有必要的标题或SDK的,因为这是由你(用户)安装,然后指向那些在你的设置文件。

The Visual Studio IDE, on the other hand, is a complete integrated development environment that also includes the system headers and SDK's for Windows, as well as the binaries to properly compile, link and assemble your code into a binary for a Windows system (cross platform is possible as well).另一方面,Visual Studio IDE 是一个完整的集成开发环境,它还包括用于 Windows 的系统头文件和 SDK,以及用于正确编译、链接和组装代码的二进制文件,用于 Windows 系统(交叉平台也是可能的)。 The Visual Studio IDE comes in many different flavors with the latest being VS 2017. Visual Studio IDE 有许多不同的风格,最新的是 VS 2017。

If you wish to stick with VS Code, you'll need to grab a compiler and the appropriate header files for the system you're targeting.如果你想坚持使用 VS Code,你需要为你的目标系统获取编译器和适当的头文件。 If you wish to just stick with Windows for now, you can grab the Windows 7 SDK here or the Windows 10 SDK here .. you could even grab both and just reference the one you wish when you want.如果您现在只想坚持使用 Windows,您可以在 此处获取Windows 7 SDK或在 此处获取Windows 10 SDK ..您甚至可以同时获取两者并在需要时引用您希望的那个。 Note that the Windows 7 SDK includes the Microsoft C/C++ compiler, alternatively you can download the MSVC compiler from their Build Tools site.请注意,Windows 7 SDK 包括 Microsoft C/C++ 编译器,或者您可以从其构建工具站点下载 MSVC 编译器。

There's also Cygwin in which you can use the GNU compiler , and of course Clang , which can be referenced in both VS Code and the VS IDE.还有Cygwin ,您可以在其中使用GNU 编译器,当然还有Clang ,它可以在 VS Code 和 VS IDE 中引用。

I hope that can help.我希望能有所帮助。

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

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