Skip to main content
GameDev.net gamedev.net
🔒 Locked

.h and .cpp file location problem

Started by SMcNeil Oct 9, 2006 at 5:40 PM 4 replies 800+ views
Original Post
SMcNeil
SMcNeil
Hi, I've had to restructure my project so that *.h and *.cpp are not clumped together in one folder. I have for example CEngine.h/.cpp in a CEngine folder, CMaterial.h/.cpp in a CMaterial folders. Now when I for example have a XXXX.h header file, I should be able to do "#include ../CEngine/CEngine.h", right? However, the compiler is throwing an error "#include ../CEngine/CEngine.h not found". The directory folder structure is as follows:
[SOURCE]
++MyProject
  Myproject.vproj
  MyProject.sln
  etc.... 
  ++Source (Folder)
      ++CEngine (Folder with .cpp & .h inside )
      ++CMaterial (Folder with .cpp & .hinside )
      ++CLight (Folder with .cpp & .h inside )
[/SOURCE]
Any thoughts as to why the compiler can't see the .h file(s)? I am using VS 7 I've also tried: "#include ../Source/CEngine/CEngine.h but this also does not work. Thanks, Sabrina
Demus79
Demus79

How about :

#include "..\somedir\someheader.h"

?

Works fine with MSVC

Cheers !
erissian
erissian
It should work with #include "../dir/file.h", but it may be more convenient if you add the directories to your include path under the project options.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
jeroenb
jeroenb
For crossplatform sake I would recommend:

#include "../dir/file.h"

Also do not use the < and > characters instead of the ", which are only valid for system files, and those will not work for local directories (I found this out the hard way too in MSVC, while it worked with GCC on Linux).
Crafter 2D: the open source 2D game framework ?Github: https://github.com/crafter2d/crafter2d
Twitter: [twitter]crafter_2d[/twitter]
Jaymar
Jaymar
Quote:
Original post by jeroenb
Also do not use the < and > characters instead of the ", which are only valid for system files

IIRC the standard says that the only difference between using "include" and is that "include" will look in the current directory and will not.

SMcNeil
SMcNeil

Hi guys,

Thanks for the posts. It seems like a trivial task to figure out, however I have tried the methods mentioned with no success. I stuck doing is somewhat stupid way,
"C:\Documents and Settings\...\...\MyProject\Source\Somefolder\Somefile.h". Seems that MSVS 7 should be smart enought to figure out where the files are. OH-WELL!
I'll keep trying to figure this out.

Thanks!

Sabrina

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.