By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Regarding changing directories

P: 48

I am working on VC++. All the source files that I use for compiling the program are kept in the current working directory.
But I would like to specify different folders/paths for inputs when compiling the same program instead of putting it in the current working directory.

How can I do that.

Please help.

Aug 11 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,197
Change your project properties to add additional include directory paths for the preprocessor.

This can be done for an individual project:
Project/Properties/C-C++/Proprocessor. Here you can add many paths separated by semi-colons or use the convenient navigation ... provided.

Or fo all projects:

Tools/Options/Projects and Solutions/VC++ Directories. Here you can add paths for includes, libraries, source files, etc. Paths will be searched in the order they appear in the dialog box.

Then move your header files to the correct locations.


Everything should still work.

The preprocessor looks for #include <header.h> along one of these paths.
The preprocessor looks for #include "header.h" in current working directory (where your project files are located) first and if the header is not there, it reverts to #include <header.h>.

Personally, I woukld change all #include "filename" to #include <filename>. Then if you need to fiddle with the header you can make a copy of it, put it back in the project directory and change the include for that one file back to #include "filename" for your builds. When it works, copy the revised header back to its correct folder and change the #include back to #include <filename>.
Aug 11 '07 #2

P: 48
Thanks for the reply.

In the main program if I need to specify that change to another particular directory for a file, then what code can I write for that.

In the program, I want to specify by code that I am changing to this particular directory. How to do that.

Aug 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.