#242 Dependncy analysis of C/C++ #include "" vs <> incorrect

open
nobody
None
5
2010-11-27
2010-11-27
David Klaus
No

The dependency analysis of C/C++ #include statements does not correctly differentiate between the double quote ("") vs. the greater than/less than (<>) method of specifying a file. The clearest write-up I can find of the difference is from the gcc preprocessor:

#include <file>
This variant is used for system header files. It searches for a file named file in a list of directories specified by you, then in a standard list of system directories. You specify directories to search for header files with the command option '-I'. The option '-nostdinc' inhibits searching the standard system directories; in this case only the directories you specify are searched.
The argument file may not contain a `>' character. It may, however, contain a `<' character.

#include "file"
This variant is used for header files of your own program. It searches for a file named file first in the current directory, then in the same directories used for system header files. The current directory is the directory of the current input file. It is tried first because it is presumed to be the location of the files that the current input file refers to.

cpptasks is always applying the latter option for C header files, preventing correct overriding of system header files when '<>' has been used to specify them.

Coding Notes: This source of this is in AbstractCompiler.java in method parseIncludes. Where it has a series of calls to the resolveInclude method, the first call passes 'sourcePath' which is the path of the file currently being processed. This call should be done conditionally for C header files only if "" was used to specify them.

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks