Friday, July 31, 2009

Inlcude files in visual c++ not found (new to c++)?

How does include files work in Microsoft Visual C? For example I have:





#include "DirOne/DirTwo/MrDo.h"





From which base directory is this? Where does it start looking for this? Why is a forward slash used and not a backslash? Can I change the directories in which VC will look (make more available?)

Inlcude files in visual c++ not found (new to c++)?
If I'm not mistaken it usually starts wherever you save your C++ file that you are working on. So if you saved your program in the directory "DirOne" it would start with the "DirOne" directory. Check to make sure where your program is saved and you can go from there.


Good Luck :)
Reply:The #include functionality would depend on the compiler, but generally the directory where the cpp file is located is searched.





For Visual C++ then any directory specified by the /I option is searched followed by any directory specified by the INCLUDE environment variable.





Also a forward slash is used because every other compiler does so, so even if Windows uses back slashes, Visual C++ uses forward slashes to keep compatability.


No comments:

Post a Comment