This is truely a beginners question

Started by
7 comments, last by Adam Hamilton 17 years, 7 months ago
i've been trying my luck at writting a 2d game in directdraw, and the file is getting too large... i want to add my own header files and other source files... i'm useing visual studio 6 so visual c++ 6... i added a header file called game.h to my project and copied some globals and structures in there.. then on the C++ file i added #include "game.h" and i get the error that game.h can't be opened because file or directory doesn't exist... and another note... the game.h file is in the same directory as my project... any help would be appreciated greately.
Advertisement
did you forget to save the game.h file by chance?
Simplicity is the ultimate sophistication. – Leonardo da Vinci
Throw up a screenshot of VS open along with an explorer window showing your code. That, I'd think would be the best way to help us help you.
"I'd rather know one thing, no matter how ordinary, than discourse endlessly on great issues." -- Galileo
Quote:Original post by ForeverNoobie
did you forget to save the game.h file by chance?


Most likely if he's a beginner, he didn't modify Visual C++ and it should save every time you try to compile (this can be a curse or blessing, depending how you look at i).

When you mean its in the same directory as your poject, is it in the same directory as the actual workspace file? If you created a workspace in directory C:\Foo, and your project is in C:\Foo\Bar, you'll want to #include "BAR\game.h". It wouldn't matter that you included the header file into your project, as it wouldn't be looking there.

If that isn't the case, then you could under worst case scenarios, is under the settings to visual studio, tell it to use that directory for includes.
I'd suggest getting MSVC++2005 as well. It's free for life, from Microsoft. Keep in mind MS dropped support for version 6.0 with Direct3D a while ago (although DirectDraw itself, which is part of Direct3D, shouldn't experience any problems). And version 6.0 is far less standards compliant. And 2005 is just way better.
[ search: google ][ programming: msdn | boost | opengl ][ languages: nihongo ]
yeah it saves when i compile, i figure it will be fine for now doing that, and it is also in the same folder as my workspace. :) any other ideas? i'll try the settigns and see if i can include it there.
did you add the file to your project?



if the file is located in some other folder did you set the include path?
Okay... here is the deal... i have a folder with my source code and my bitmaps and the game.h file. I also rightclicked my Header Files and added the game.h to the workspace... do i have to do anything else... i mean i obviously must be missing something because the compiler error says it can't find the file... so do i have to officially insert it into the project? or change some settings around?
You shouldn't need to add it in your project but it is a good idea too.

Are you including like this:

#include <game.h>

or this

#include "game.h"

because the way you should be doing it is the second way

#include <game.h> would look in your include paths which I bet doesn't include your project directory. (However, I am not sure that once it finishes looking in the include paths, it will look in the current directory)

#include "game.h" would look in the directory where your project is located.

This topic is closed to new replies.

Advertisement