简体   繁体   中英

C++ project is not finding its header files (visual studio)

I have not used C++ in visual studio in a lonnng lonnng time so probably this is a basic question but I would like some help.

I am opening someone else C++ code and the first thing I notice is that it is not recognizing its includes.

For example I have a main.cpp that has

#include "stdafx.h"
#include "myheader.h"

this cpp file is inside a "source" folder and those header files are under a "headers" folder.

I got an error "cannot open source file "stdafx.h" and "cannot open source file "myheader.h"

It is been ages I haven't touched C++ in visual studio. What configuration I should do to fix this?

if source and headers folders are in same level in folder structure you can use

#include "..\headers\myheader.h"

Similarly locate your stdafx.h and add the relative path to the .cpp file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM