Hard coded path names
-
How else to easily share code between projects? Right now I have MSVC create project subfolders of the c:\devel directory and I have a bunch of .cpp and .h files for common functions in a c:\classes directory. Whenever I need a frequently used class I just 'add files to project' from c:\classes and then #include "c:\classes\foo.h". I've never worked on projects with other people before, but I can see that I should find another way to do it in case I have the opportunity to collaborate in the future.
-
How else to easily share code between projects? Right now I have MSVC create project subfolders of the c:\devel directory and I have a bunch of .cpp and .h files for common functions in a c:\classes directory. Whenever I need a frequently used class I just 'add files to project' from c:\classes and then #include "c:\classes\foo.h". I've never worked on projects with other people before, but I can see that I should find another way to do it in case I have the opportunity to collaborate in the future.
-
How else to easily share code between projects? Right now I have MSVC create project subfolders of the c:\devel directory and I have a bunch of .cpp and .h files for common functions in a c:\classes directory. Whenever I need a frequently used class I just 'add files to project' from c:\classes and then #include "c:\classes\foo.h". I've never worked on projects with other people before, but I can see that I should find another way to do it in case I have the opportunity to collaborate in the future.
First, it's a good idea for everyone to have the same directory structure (if for no other reason that to serve as a common frame of reference). For instance, I have the following directory structure for ne of my projects:
\Johns Projects\ --- CommonFiles
--- DeMONS2\ --- D2CommonFiles
--- D2Config
--- D2Launcher
--- D2ScrubWith the directory structure described above, any project in the johns projects root can get to any header file in CommonFiles or D2CommonFiles, even if "Johns Projects" has another name or is copied (in its entirety) to another drive altogether In your project settings dialog... 1) Click Project | Settings... in the Visual Studio menu. 2) On the left side of the dialog, you'll see a combo box labeled "Settings for:". Select "All Configurations". 3) On the right side of the dialog, select the "C++" tab, and in the combo box labeled "Category:", click the "Preprocessor" item (last one in the list). 4) In the edit field lebaleled "Additional Include Directories:", and your relative path. Using the directory structure example above, for all of the projects in the DeMONS2 folder (D2Launcher, D2Config, and D2Scrub), I used "..\..\CommonFiles,..\D2CommonFiles". At this point, all you have to do is #include the filename itself without worrying about the path at all. In order to share a project, everyone will find it much simpler to just have identical directory structures.