Mixed use of "include" directives with quoted vs. angle-bracketed params, causing havoc

I have multiple Boost versions installed in different file locations. I occasionally ran into problems with mixed-up Boost headers. This was due to Boost's use of both quoted and bracketed syntax of the include directive to include its headers. The standard allows for different results for resolving the include directive depending on the chosen form. In particular the angle-bracketed form is narrower than the quoted one (see chapters 16.2.2 and 3). So the point in the file system from where the file will actually be included may legally differ, based on the form of the include directive. I don't mind which alternative Boost uses. But in my opinion it should be consistent inside Boost headers, shouldn't it? With some file system layouts it gets very inconvenient to pre-determine by simple set-up of compiler or environment variables which version will get used. I also fail to see any obvious downside of a unification.

on Sat Sep 06 2008, "Victor Vojtech Terber" <victor-AT-terber.de> wrote:
Me neither, except that in very rare cases it could break some peoples' builds when they upgrade. The biggest obstacle, IIRC, was that we had a hard time coming to an agreement about which convention to use. However, I may have been the only one holding out for <> and since I realized that other libraries were using "" I never use <> anymore. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

David Abrahams wrote:
I was also holding out for <>. And recently become ardently in favor of <>. For the simple reason that some compilers [0] have essentially zero control of what the "" includes do. I ran into problems with a library that uses "", but I needed to 'patch' some of the library files. Might not sound like a big problem but since the library is one that gets updated continuously I get it directly from their SVN repo. Which means that the common way of patching, by literally changing the source code, is problematic in that it introduces extra management steps. My preferred approach is of course to add my patched includes at the front of the include path. But that solution doesn't work since the files in the lib get included first because of the fixed behavior of "" includes (of including relative to the including file first). [0] The compiler I'm referring to is msvc. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
[0] The compiler I'm referring to is msvc.
And another data point: I had a bug request to change "" to <> in type_traits because of the way Metrowerks handles "". So that's +1 for <> from me too. Philosophically it feel right too: "" is for user header files, <> is for libraries outside of the users control. John.

John Maddock wrote:
So that's +1 for <> from me too.
+1 from me as original poster also. A bit grepping suggests that the angle-bracketed form is used much more widely than the quoted one inside Boost. But there is a catch: In many places "include SOMEMACRO" is used, which often (mostly?) expands into quoted parameters. An example is macro "BOOST_PP_STRINGIZE" used with "include" at over a dozen locations inside MPL (this actually blew up my configuration in the first place). A nice example is also BOOST_COMPILER_CONFIG and friends. While in file boost\config\user.hpp its use is proposed with angle brackets, the actual defines in boost\config\select_compiler_config.hpp are quoted. As I'm new to the Boost devel process: Should I (or anyone else) enter a ticket, or doesn't that make sense before further discussion occurred?

Victor V. Terber wrote:
Oh :-( That would be me, I seem to remember there was actually a reason for this, if you use #include <somename.hpp> and "somename" happens to be a macro then it gets macro expanded, and there are some platforms that define for example: #define linux 1 which causes: #include <boost/config/platform/linux.hpp> to blow up :-( The only workaround would be to obfuscate the file names to boost_linux_config.hpp or something which is equally ugly ("linux" isn't the only culptrit BTW, but is the most common one).
Well, since it's provoked some discussion, lets see what happens.... Cheers, John.

On Sat, Sep 6, 2008 at 11:13 PM, Rene Rivera <grafikrobot@gmail.com> wrote:
What exactly do you mean zero control? What kind of control are you looking for? Order of searched include paths?
I think I understand what you are describing, which version? Order of include paths works just fine with their compilers for me since 2003 unless I am misunderstanding you. I frequently simply put a patched directory of boost above my main boost install and it always picks up the patched header files first. Now, isn't there a slight performance and semantic difference that should lead to using "" and not <>? Doesn't <> mean search compiler dependent search path for file, then search user supplied paths in order supplied, and "" means search user supplied path in order supplied, then fall back to compiler dependent path? If so, "" should clearly win. --Michael Fawcett

Michael Fawcett wrote:
For MSVS22005 see http://msdn.microsoft.com/en-us/library/36k2cdd4(VS.80).aspx.

On Sun, Sep 7, 2008 at 12:37 PM, Victor V. Terber <victor@terber.de> wrote:
I think that means for libraries it makes more sense to use angle brackets. Boost headers don't rely on any such thing as a "current directory", they require the boost path in the include search path, therefore, the semantics (and maybe performance?) favor angle brackets.
Thanks for the reference, I didn't have a copy handy at home (only at work). --Michael Fawcett

Michael Fawcett wrote:
No, while this is all implementation defined, on every compiler I've used <> will always search paths supplied with -I directives before system paths. One could argue that "" is less efficient because it *may* search paths relative to the current file before looking at -I paths. But frankly any argument on efficiency grounds is likely to be fallacious: all strictly IMO of course! John.

Michael Fawcett wrote:
You can't change the in any way the implementation defined aspect of ("") includes that differs from the (<>) includes. For example some compilers let you specify to treat ("") the same as (<>). Or to specify the ("") searched path independent of the (<>) searched paths.
What kind of control are you looking for? Order of searched include paths?
In the case of my use case I needed a way to remove "searching relative to the including file directory" aspect of ("") includes. This is because the library includes headers as (include "a.h") which *never* gets around to searching extra include paths I specify because it always finds the one in the including dir first.
All of them. Or rather msvc6, msvc7, msvc8, and msvc9. Although I've used msvc1 long ago, I don't remember if it had the same "limitation" ;-)
You misunderstood. Specifying the search paths works. But removing the local including dir from the search path is impossible.
That would be because AFAIK all Boost headers start with "boost/..." and don't reference local includes. But moving to preferring ("") will likely encourage library authors to rely on what is essentially non-portable compiler behavior. The use of (<>) includes is technically also non-portable but is currently universally portable or can be made that way. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

On Sun, Sep 7, 2008 at 2:21 PM, Rene Rivera <grafikrobot@gmail.com> wrote:
Ah, now I see the problem. I misunderstood.
You misunderstood. Specifying the search paths works. But removing the local including dir from the search path is impossible.
Indeed.
So it sounds like libraries should prefer <>, and the only time "" should be used is in project specific headers (i.e. won't be reused). But then often times project specific code ends up being generalized into a library at a later date, at which point it should be <>, so shouldn't you just always use <> then? --Michael Fawcett

On Sun, Sep 7, 2008 at 6:55 PM, Michael Fawcett <michael.fawcett@gmail.com>wrote:
I only use "" in source (.cpp) files for including headers that live in the same directory, in which case I don't qualify the filename w/ a directory prefix. I basically use <> for everything else, qualified w/ the top-most directory prefix (e.g. #include <boost/.../foo.hpp>). Using the directory-qualified includes is especially important in library headers so that the compiler is happy when building the library itself, as well as when building against the library. However, I find that always including in this fashion, even in stand-alone executables, makes it easier to move code into a library later. Using <> by default works well for me because I like to use -I to control include order. I like to specify a single -I for the library, and dont want the CPP to search the current directory first, which is what one of the compilers that I use will do if I use "". And perhaps I'm also a bit superstitious. ;-) Jon
participants (8)
-
David Abrahams
-
Gennaro Prota
-
John Maddock
-
Jonathan Franklin
-
Michael Fawcett
-
Rene Rivera
-
Victor V. Terber
-
Victor Vojtech Terber