Two header files with same name. want to use latest version

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dipanwita
    New Member
    • Aug 2007
    • 6

    Two header files with same name. want to use latest version

    I have been working in VC++ 6.0. There are two header files with same name.The path of old version is included via "TOOLS/option/directories"
    I want to use new version though don't want to change the old version and settings. how come it be possible ??? Is namespace a solution??? how to use it ??
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Alter your compiler include path to use the directory of the new file instead of the directory of the old file.

    Alternitively if you can not remove the directory of the old file then alter your compiler include path to include the directory of the new file before the old directory, the compiler will use the first file it finds. However personally I do not like this reliance on the operation of the compiler. In my opinion a project should really only include 1 file with a given name.

    Comment

    • Dipanwita
      New Member
      • Aug 2007
      • 6

      #3
      Originally posted by Banfa
      Alter your compiler include path to use the directory of the new file instead of the directory of the old file.

      Alternitively if you can not remove the directory of the old file then alter your compiler include path to include the directory of the new file before the old directory, the compiler will use the first file it finds. However personally I do not like this reliance on the operation of the compiler. In my opinion a project should really only include 1 file with a given name.
      Thank u very much for the reply. But the fact is that I can't change the path since the old version is used by another project. So if I swap the position of path then old project will be hampered.Can't i handle this problem using namespace???

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by Dipanwita
        Thank u very much for the reply. But the fact is that I can't change the path since the old version is used by another project. So if I swap the position of path then old project will be hampered.Can't i handle this problem using namespace???
        You can not use a namespace because you problem is that the files have the same name. A namespace is created inside a file so you have to be able to open the file first to be able to use a namespace.

        Changing the path in 1 project will not effect the path in another project. You would on get a problem if you changed the directory structure or file locations on disk.

        I am not suggesting that I am suggesting altering the include path you pass to the compiler. This alters where the compiler looks for files on the disk not where the files are. Look In

        Projects -> Settings -> C/C++ (Tab) -> Preprocessor (Category) -> Additional Include Paths (Text Box)

        Set your paths here to the project include directories that you wish to include files from.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          Originally posted by Dipanwita
          The path of old version is included via "TOOLS/option/directories"
          This path would apply to all projects. To use a special path, just add your path before the path shown in "TOOLS/option/directories". The preprocessor searches the paths in the order listed.

          This way one fix an apply to all projects. Otherwise, follow Banfa's advice to restrict the path to one project.

          Comment

          Working...