User forums > General (but related to Code::Blocks)
Moving to GCC question
Michael:
--- Quote from: troels on January 18, 2006, 02:56:31 pm ---
--- Quote from: Michael on January 18, 2006, 02:49:08 pm ---
--- Code: ---#include "./mylib/include/mylib.h"
--- End code ---
The problem is when you give a relative path: from where begin the search?
--- End quote ---
I believe it's fairly clear, apostrophes ("") means 'here' (the location of the .c file with the #include in it), lessthan-greaterthan (<>) means search include paths (first). But I could be wrong I guess.
--- End quote ---
Well, may be with VC++ 6. It works fine there. But with C::B not. May be a C::B dev can give some further info or instead confirms that I am wrong :).
Michael
thomas:
http://www.cppreference.com/preprocessor/include.html
EDIT:
The exact method supported by gcc is specified by C99, as described here: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf on page 149
TDragon:
--- Quote from: Michael on January 18, 2006, 02:49:08 pm ---The problem is when you give a relative path: from where begin the search?
--- End quote ---
Spot on.
From what I've seen, the critical difference lies between specifying a qualified path (one with slashes) and a plain filename. For an include directive that only specifies a file name, GCC looks in the directory it was invoked from, the directory the file being compiled is in, and any additional directories specified with the -I option. For an include directive that specifies an absolute or relative qualified path, apparently it looks in the directory it was invoked from and any additional directories from the -I option, but NOT the directory the file being compiled is in. Code::Blocks calls GCC from the directory your .cbp file is in, so this is probably where your compilation is going wrong.
troels:
--- Quote from: TDragon on January 18, 2006, 04:04:49 pm ---...apparently it looks in the directory it was invoked from...but NOT the directory the file being compiled is in
--- End quote ---
Excellent! Thanks TDragon!
I've posted a bug report, #1409127.
Regards
Troels
TDragon:
Now that I've posted all that, I'm not so sure anymore; look at the directory structure for one of my projects:
--- Code: ---Cklo
|- Source
|- Engine
| |- Engine.cpp {#include "../base.h"}
|- base.h
--- End code ---
Engine.cpp compiles without adding the "Engine" directory to the include paths. So my answer before appears to be wrong.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version