Thread: How do Including Paths Work?

  1. #1
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229

    How do Including Paths Work?

    Hi,

    So I wrote a bunch of classes for an old project that I want to use in a new project. So I put each of the classes in its own directory (the h and cpp file), then put all those directories on in the top level of my project. Some of the classes are dependent upon each other, and originally all this source was just in the same directory. If a c or h file has an include with quotes "" where is it looking?

    If one of the classes is including another class, Can I just do:
    "class_directory/class.h"
    or should it be:
    "../class_directory/class.h"

    Maybe this is all dependent on the ide?

    Thanks, I couldn't find any info about this, didn't really know what I was searching for.

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    AFAIK
    "myheader.h" looks in the pwd.

    "../myheader.h" looks in its parent dir.

    And this behaviour isn't dependent on any thing. (I don't know if it can be modified by something in the makefile, though )

  3. #3
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    Alright, so any includes in a source file are going to look in their own working directory. I always get hung up on the simple stuff :P

    Thanks for the help though.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    They would look in the directory they are lying... files cannot have a working directory I presume; that would be reserved for applications.
    I cannot help but notice the ".c" though. If this is supposed to be C, then you posted on the wrong board!
    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.

  5. #5
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by Elysia View Post
    They would look in the directory they are lying... files cannot have a working directory I presume; that would be reserved for applications.
    I cannot help but notice the ".c" though. If this is supposed to be C, then you posted on the wrong board!
    It'd then be the compiler's working dir, when reading that file .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Exec and paths
    By Imanuel in forum C Programming
    Replies: 4
    Last Post: 07-31-2010, 03:00 PM
  2. Ignore paths???
    By gransken in forum C++ Programming
    Replies: 12
    Last Post: 11-29-2008, 05:30 AM
  3. Including math.h doesn't seem to work?
    By scorpion_gr in forum C Programming
    Replies: 5
    Last Post: 08-07-2007, 09:34 AM
  4. How do I add include paths in GCC?
    By kinghajj in forum Linux Programming
    Replies: 2
    Last Post: 08-01-2003, 06:17 AM
  5. tcp/ip paths to sites??
    By iain in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-05-2002, 06:39 PM