Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Hard coded path names

Hard coded path names

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Griffing
    wrote on last edited by
    #1

    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.

    L realJSOPR 2 Replies Last reply
    0
    • A Alex Griffing

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Always use #include with relative path for example #include "..\classes\foo.h" , in this way you will be able to move the project with out any problems.

      1 Reply Last reply
      0
      • A Alex Griffing

        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.

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        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
        --- D2Scrub

        With 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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups