user1943827
user1943827

Reputation: 123

Can't open header file in C++

I have a header file called simpio.h, which is in the same folder as the file which is including it in its header. However, I keep on getting the error "Cannot open include file: 'simpio.h': No such file or directory." I am using Visual C++ 2008 Express Edition. Help would be appreciated.

Thanks

Upvotes: 2

Views: 10063

Answers (2)

Pierre Fourgeaud
Pierre Fourgeaud

Reputation: 14510

You have to know that you should use <> when you are trying to include a standard library header or when you want to include a file for which the path is contained in the Additional include directories option.

You have to use "" when you whant to include a file who doesn't satified the previous explanation, let's say that it is almost always file specific to your project.

Some example :

#include <iostream>           // library file
#include <boost/thread.hpp>   // there is "C:\SDKS\boost in my Additional include directories

#include "MyHeader.h"             // Local file, at the same place of my .vcproj
#include "Header/AnotherHeader.h" // Local file in a folder named "Header"

In your case, we can think that you are in the second case. You just have to do :

#include "simpio.h"

Or if your file is in another folder :

#include "SomeFolders/simpio.h"

Upvotes: 3

Sector95
Sector95

Reputation: 641

You need to use double quotes:

#include "simpio.h"

Upvotes: 4

Related Questions