Reputation: 1
I'm working on a project that system headers can appear in "" and also in <>
for example: "io.h"
and <io.h>
I need to determine if the included header is a customer one or not.
someone knows if there is a way to do it?
Upvotes: 0
Views: 129
Reputation: 129314
Aside from "asking the compiler", there is no trivial way to determine if "io.h"
or <io.h>
is taken from a local directory or somewhere in the standard headers. For example, a program will compile perfectly happily with #include "iostream"
.
The main difference is that the compiler will look FIRST in the local directory for the file "io.h" when using "io.h"
, where if you use <io.h>
it will look in the include directories specified as "system include directories". However, there is nothing saying that system include directories does not include "current directory" in one way or another.
You can use g++ -M myfile.cpp
to list what include files are used in the file "myfile.cpp". Unfortunately, as far as I can tell, there is no such option for Visual Studio.
Edit: The MS compiler does indeed support a similar feature using the /showinclude
option.
Upvotes: 2
Reputation: 76057
Take a look to the documentation of your compiler, for example the MS C++ compiler will check system includes after local with quotes (so #include "io.h"
will get the system include if there are no io.h
local header files), but it won't look locally for angled brackets:
http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx
I guess that you will have to manually check for project files if there are names collisions for include files.
Upvotes: 0