CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Posts
    382

    #include question

    For starters I'm using Visual C++ 2008 Express Edition.

    That aside, I have a visual studio solution test_project within a directory called test_project. IOW my directory structure is akin to:

    c:\code\test_project
    test_project.sln
    test_project.vcproj
    test_project.ncb
    main.cpp
    - executive
    executive.h
    executive.cpp
    - common
    common_header.h

    Where within the directory test project there's two directories: "common and executive". Within the common directory there's a file named: "common_header.h". Within the executive directory I have two files: executive.h and executive.cpp

    I added an environment variable to my system called: "TEST" with the directory: c:\code
    Within my visual studio project I added the following line to my "VC++ Directories".
    $(TEST)\test_project\common

    From the Project Menu I selected Show All Files which imported the folders common and executive. I then right clicked and added each file within the folders

    Later I ammended main to reflect
    Code:
     # include "common\common_header.h"
     # include "executive\executive.h"
      int main() {
    
      }
    At issue: I'd like to eliminate the need to specify the directory within the source files. i.e I want to do: # include "common_header.h" as opposed to "# include "common\common_header.h". Trouble is the former generates a compiler error:
    fatal error C1083: Cannot open include file: "common_header.h".

    How do I circumvent this?

  2. #2
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: #include question

    [Moved Thread]

    First, please post the question to the relevant board. It helps to get the question answered quickly and accurately.

    Next, you can achieve that you setting the "common" folder path in the project settings (i.e. Project Properties -> C/C++ -> Additional Include Directories).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured