Cannot open include file with Visual Studio(无法使用 Visual Studio 打开包含文件)
问题描述
我最近从 Code::Blocks 转到 Visual Studio,并在Code::Blocks 可以只添加一个类,然后立即包含它.但是,每当我在 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?
这是相关类的代码:
#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 打开包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法使用 Visual Studio 打开包含文件
- c++ const 成员函数,返回一个 const 指针.但是返回的指针是什么类型的 const? 2022-10-11
- C++ 数据结构超详细讲解顺序表 2023-03-25
- 我应该为我的项目使用相对包含路径,还是将包含目录放在包含路径上? 2022-10-30
- C语言详解float类型在内存中的存储方式 2023-03-27
- ubuntu下C/C++获取剩余内存 2023-09-18
- C语言qsort()函数的使用方法详解 2023-04-26
- Easyx实现扫雷游戏 2023-02-06
- C语言手把手带你掌握带头双向循环链表 2023-04-03
- 详解C语言中sizeof如何在自定义函数中正常工作 2023-04-09
- Qt计时器使用方法详解 2023-05-30