无法打开包含文件,与visual studio [英] Cannot open include file, with visual studio

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

问题描述

我最近从代码块到Visual Studio,在codeBlocks只需添加一个类,然后立即包含它。但是,当我在Visual Vtudio中使用以下语句做同样的事情:

  #includeincludedFile.h

  #includeinclude / includedFile.h

它不工作,


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


有没有一些框或设置,或者,我必须手动添加每个头作为依赖关系吗?



下面是有问题的类的代码:



Public.h:

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

Public.cpp:

  #includePublic.h


Public :: Public(void)
{
}


Public ::〜Public(void)
{
}

如何包含它:

  #includePublic.h

p>

解决方案

默认情况下,Visual Studio在您的项目的文件夹($ ProjectDir)默认标准库目录。如果您需要包含未放在项目目录中的内容,则需要添加要包括的文件夹的路径:



转到您的项目属性(项目 - >属性 - >配置属性 - > C / C ++ - >常规)和字段其他包括目录添加到.h文件的路径。



您也可以按照Chris Olen的建议,添加VC ++ Directories字段的路径。


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

#include "includedFile.h"

or

#include "include/includedFile.h"

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

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:

Public.h:

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

Public.cpp:

    #include "Public.h"


    Public::Public(void)
    {
    }


    Public::~Public(void)
    {
    }

How it is being included:

    #include "Public.h"

解决方案

By default, Visual Studio searches for headers in the folder where your project is ($ProjectDir) and in the default standard libraries directories. If you need to include something that is not placed in your project directory, you need to add the path to the folder to include:

Go to your Project properties (Project -> Properties -> Configuration Properties -> C/C++ -> General) and in the field Additional Include Directories add the path to your .h file.

You can, also, as suggested by Chris Olen, add the path to VC++ Directories field.

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

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