Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Header Files in Visual C++ question

Status
Not open for further replies.

Photovalve

Programmer
Nov 15, 2003
2
GB
I'm sure this is an obvious question for those in the know. I am fairly new to Visual C++ and have always had a problem with header files. Adding

#include <stdio.h>

causes no problem. It's when I want to include my own, local header files. I go to

Settings>>Add to Project>>Files

and add the header files I need. They duly appear in my project window and I refer to them using

#include &quot;myheader.h&quot;

but when I try to compile my C code I always seem to get a

&quot;cannot find myheader.h&quot; error.

I'm sure this is really simple but I've never beena ble to ask anyone before. I'd really appreciate tips.

Thanks

Photovalve
 
Where are your header files stored ?
are you including in them in the file that needs to use the functions / classes in your .h file ?
 
Is that am I including in them or am I including them in? Not quite sure what you mean. What I have done now is go to Tools>>Options>>Directories and added my header folder in there. That seems to have worked but now the linker fails for another reason.

By the way, do you know how to call a dll from Visual C code?

Thanks for your reply

Malcolm
 
put the header files in the same folder that you're compiling your .cpp program in.

don't need to go to settings, add to project or anything like that.

example:

#include<iostream> // <> are for header files in the visual c++ designated folder

#include &quot;c:\windows\users\folder1\header1.h&quot; // your own header

you can short that full path down to just the name if it's in the local folder:

#include &quot;header1.h&quot;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top