header path & include

This is a discussion on header path & include within the C++ Programming forums, part of the General Programming Boards category; Folder ( directory) hierarchy is like this: FolderRoot/FolderX/FolderY/main.c FolderRoot/FolderZ/header.h How to include (write) header.h into main.c #include "../../??????header.h" ??...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    7

    header path & include

    Folder ( directory) hierarchy is like this:

    FolderRoot/FolderX/FolderY/main.c
    FolderRoot/FolderZ/header.h

    How to include (write) header.h into main.c

    #include "../../??????header.h" ??

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,918
    #include "../../FolderZ/header.h"
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    If you are using GCC then you could just include the path to the headers like normal:
    in main.c:
    #include "header.h"

    Then when compiling:
    gcc main.c -I/FolderRoot/FolderZ/ -o myApp

    Or this can be set in the Makefile if you are using that. Typically hardcoding even relative paths into include statements is bad juju.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    7
    thx, guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Precompiled header question
    By donglee in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2009, 01:23 AM
  2. where to include header files?
    By kaos_frack in forum C++ Programming
    Replies: 6
    Last Post: 12-30-2008, 03:09 PM
  3. to #include or not to #include
    By krygen in forum C++ Programming
    Replies: 9
    Last Post: 12-25-2004, 12:06 AM
  4. help with finding lowest number entered
    By volk in forum C++ Programming
    Replies: 12
    Last Post: 03-22-2003, 01:21 PM
  5. Replies: 6
    Last Post: 04-02-2002, 05:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21