如何使用尖括号让 Visual Studio 2017 看到我的 .h 文件? [英] How to make Visual Studio 2017 see my .h file using angle brackets?

查看:35
本文介绍了如何使用尖括号让 Visual Studio 2017 看到我的 .h 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Visual Studio 2017 解决方案和 C++ 项目,其中包含一个名为 Source.cpp 的源文件.在 Source.cpp 中,我有 #include <FL/Fl.H> 显示为红色下划线,因为 Visual Studio 找不到它.

I have a Visual Studio 2017 solution and C++ project with one source file called Source.cpp. Inside Source.cpp I have #include <FL/Fl.H> which appears red underlined because Visual Studio cannot find it.

在我的文件系统上,我已验证文件 c:\fltk\include\FL\Fl.H 存在,然后我右键单击我的项目并添加目录 c:\fltk\include 到项目Include Directories.

On my file system, I have verified that the file c:\fltk\include\FL\Fl.H exists, and I right clicked my project and added the directory c:\fltk\include into the project Include Directories.

希望这张照片可以解释我的沮丧

Hopefully this picture can explain my frustration

如何让 Visual Studio 2017 包含文件?

How can I get Visual Studio 2017 to include the file?

推荐答案

答案与解决方案平台解决方案配置

正如您在屏幕截图中看到的,属性页设置为编辑配置:发布平台:x64,这与我的活动解决方案平台"不同"和活动解决方案配置",分别设置为 Debugx86.请参阅下面的屏幕截图.

As you can see in the screenshot, the property pages are set to edit Configuration: Release and Platform: x64 which happened to be different from my "Active Solution Platform" and "Active solution configuration" which was set to Debug and x86 respectively. See the screenshot below.

当我切换到配置:所有配置平台:所有平台,然后添加包含文件夹时,一切正常!请参阅下面的屏幕截图.

When I switched to Configuration: All Configurations and Platform: All Platforms and then added the include folder, everything worked! See the screenshot below.

另请注意,我从使用 VC++ 目录 选项组更改为 C/C++ 选项组.虽然这里有一些解释 包含目录"有什么区别?和其他包含目录"

Also note I changed from using the VC++ Directories option group to the C/C++ option group. I haven't quite understood what the difference is although there are some explanations here What is the difference between "Include Directories" and "Additional Include Directories"

我仍然不清楚为什么这个问题被否决了,但我认为这个答案可能对其他犯了同样错误的 Visual Studio 新手有用.

I'm still unclear why this question got downvoted, but I think this answer will probably be useful to other Visual Studio newbies who made the same mistake I did.

这篇关于如何使用尖括号让 Visual Studio 2017 看到我的 .h 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆