IncludeFile fundamentally flawed?
Posted: Sat Nov 22, 2008 2:27 pm
The way IncludeFile/XIncludeFile works is by appending the absolute directory of the main source file to the include file. This will break any includes relative to the file in which it's declared if it's not within the same directory as the main source file.
So if I have a directory structure like this:
.. where lib1 and lib2 each use XIncludeFile("lib3.pb"), main will fail to compile with an error similar to this:
I would argue that this method of resolving include files is fundamentally flawed.
This is also unlike the behavior of the C 'quoted form' of the #INCLUDE directive:
So if I have a directory structure like this:
Code: Select all
/folder/functions/lib1.pb
/folder/functions/lib2.pb
/folder/functions/lib3.pb
/folder/main.pb
What this means is that .pb files that use either IncludeFile or XIncludeFile are not portable unless no directory hierarchy is used in the project.Line 1: File not found (V:\folder\lib3.pb).
I would argue that this method of resolving include files is fundamentally flawed.
This is also unlike the behavior of the C 'quoted form' of the #INCLUDE directive:
MSDN wrote:[Quoted form] instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of any files that include (#include) that file. The preprocessor then searches along the path specified by the /I compiler option, then along paths specified by the INCLUDE environment variable.