无法用Visual Studio打开包含文件 [英] Cannot open include file with Visual Studio

查看:389
本文介绍了无法用Visual Studio打开包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从 Code :: Blocks 转到了Visual Studio, Code :: Blocks one可以添加一个类,然后立即包含它。但是,每当我在Visual Studio中使用以下语句执行相同操作时:

I have recently gone from Code::Blocks to Visual Studio, and in Code::Blocks one could just add a class and then include it straight away. However, whenever I do the same in Visual Studio with the following statement:

#include "includedFile.h"

#include "include/includedFile.h"

它不起作用而是我收到错误:

It doesn't work and instead I get the error:


无法打开包含文件:'includedFile.h';没有这样的文件或目录。

cannot open include file: 'includedFile.h'; no such file or directory.

是否有一些盒子或设置我必须打勾?或者我是否必须手动将每个标头添加为依赖项?

Is there some box or setting that I have to tick? Or do I have to add each header as a dependency manually?

以下是相关课程的代码:

Here is the code for the class in question:

    #pragma once
    class Public
    {
        public:
            static const int SCREEN_WIDTH=1000;
            static const int SCREEN_HEIGHT=1250;
            Public(void);
            ~Public(void);
    };

Public.cpp:

Public.cpp:

    #include "Public.h"


    Public::Public(void)
    {
    }


    Public::~Public(void)
    {
    }

如何包含它:

    #include "Public.h"


推荐答案

我有同样的问题从例如gcc到Visual Studio进行C编程。 确保您的包含文件实际位于目录中 - 不仅仅显示在VS项目树中。对于我在其他语言中复制到项目树中的文件夹确实会移动文件。使用Visual Studio 2010,粘贴到头文件不会将.h文件放在那里。

I had this same issue going from e.g gcc to visual studio for C programming. Make sure your include file is actually in the directory -- not just shown in the VS project tree. For me in other languages copying into a folder in the project tree would indeed move the file in. With Visual Studio 2010, pasting into "Header Files" was NOT putting the .h file there.

请检查您的实际目录中是否存在包含文件。将它放入项目/解决方案资源管理器中的头文件文件夹是不够的。

Please check your actual directory for the presence of the include file. Putting it into the "header files" folder in project/solution explorer was not enough.

这篇关于无法用Visual Studio打开包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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