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语言基础全局变量与局部变量教程详解 2022-12-31
- C++中的atoi 函数简介 2023-01-05
- C++使用easyX库实现三星环绕效果流程详解 2023-06-26
- 一文带你了解C++中的字符替换方法 2023-07-20
- C/C++编程中const的使用详解 2023-03-26
- 如何C++使用模板特化功能 2023-03-05
- C语言 structural body结构体详解用法 2022-12-06
- C++详细实现完整图书管理功能 2023-04-04
- C利用语言实现数据结构之队列 2022-11-22
- 详解c# Emit技术 2023-03-25