Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order in which Directories are Searched Should Change, depending on Delimiter Used #27

Open
duncanmac99 opened this issue Sep 15, 2018 · 0 comments

Comments

@duncanmac99
Copy link

The manual pages for the GNU C pre-processor state, as (apparently) does the POSIX standard, that using a '#include ' will cause each of the directories named in '-I' arguments to be searched, then the system directory/ies to be searched; no mention is made of the current file's directory. However, when the line ' #include "file" ' is used, the current file's directory is searched first, ^then^ the directories named in '-I' arguments are searched; no mention is made of the system directory/ies.

If a file named by #include and in the current directory happens to have the same name as a file in the system directories (or, worse, in a directory named in the '-I' list), then '#include ' will wind up picking up the wrong file. As the code now stands, the current directory is always checked first, without regard to which delimiter is being used. Using the argument '--curdirinclast' can fix that, but only at the cost of ruining it for the other #include statements (of the form ' #include "file" '); the latter statement then runs the risk of getting the wrong file instead, from somewhere other than the current directory.

The best work-around is to ensure that each and every file-name is unique. But, for unrelated reasons, this may be very hard if not impossible to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant