Visual Studio 2008 奇怪的 C++ 和头文件 [英] Visual Studio 2008 oddity with C++ and header files

查看:42
本文介绍了Visual Studio 2008 奇怪的 C++ 和头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2008 解决方案文件中有一个大型 C++ 项目,一切都在正确编译和构建.到目前为止一切顺利.

I have a large C++ project within a Visual Studio 2008 solution file, and everything is compiling and building correctly. So far so good.

但是,当我尝试直接从 IDE 的代码查看器窗口打开它们时,它无法找到任何头文件,即使这些头文件的文件夹位置在属性"页面的其他包含路径"部分中列出.

However, it is unable to find any header files when I attempt to open them directly from the IDE's code viewer window, even though the folder locations of those header files are enumerated in the "Additional Include Paths" section of the Properties page.

例如,此 C++ 代码片段构建成功:

For example, this C++ code fragment builds successfully:

#include "ctrl_word.h"
#include "SwitchOBJ.h"

CMyLocalOBJ::CMyLocalOBJ()
{
    CSwitchOBJ cSwitchObj;
    // ...
}

但是,当我右键单击任何一个头文件的名称并选择上下文菜单选项打开文档"时,会弹出此错误对话框:

However, when I right-click over any one of the header files' names and choose the context menu option "Open Document", this error dialogue box pops up:

File "ctrl_word.h" not found in current source's directory or in build system paths.
    Current source path: 
    Build system path:
        C:\Program Files\Microsoft Visual Studio 9.0\VC\include;
        C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include;
        C:\Program Files\Microsoft SDKs\Windows\v6.0A\\Include;
        C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include

上述文件 ctrl_word.h 确实不存在于上述任何文件夹中,但构建系统通过查找其他包含目录可以毫无问题地找到它.

The aforementioned file ctrl_word.h is indeed not present in any of the above-mentioned folders, and yet the build system has no problem finding it by looking up the additional include directories.

我对此感到担忧的主要原因是,我已将其配置为在 IDE 中运行的 Lint 工具表现出类似的无法打开文件 X"行为.

The main reason I'm concerned about this is because a similar "unable to open file X" behaviour is being exhibited by a Lint tool which I've configured to run within the IDE.

对可能发生的事情有任何想法吗?

Any ideas on what could be the matter?

推荐答案

可能是 IDE 没有在其他查找目录中查找,或者您的智能感知文件已损坏.尝试在 VStudio 的全局包含目录中包含路径:工具 -> 选项 -> 项目 &解决方案 -> VC++ 目录 ->(添加你的文件夹)或

It may be that the IDE is not looking in the additional lookup directories or your intellisense file is corrupt. Try including the path in the global include directory of VStudio: Tools -> Option -> Projects & Solution -> VC++ Directories -> (Add your folders) OR

删除 Intellisense 文件(存在于每个项目目录中).它将在重新打开项目时由 VStudio 重新创建.(推荐)

Delete Intellisense file (present in each project directory). It will be recreated by VStudio on reopening the project. (RECOMMENDED)

这篇关于Visual Studio 2008 奇怪的 C++ 和头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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