Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++.moderated > #7341

Re: Include precedence <> vs "" for system libraries (Unix-like OSes)

Message-ID <41c1500a-a5ce-48ea-befa-bda3cb368b38@googlegroups.com> (permalink)
Newsgroups comp.lang.c++.moderated
From FredK <fred.l.kleinschmidt@googlemail.com>
Subject Re: Include precedence <> vs "" for system libraries (Unix-like OSes)
Organization unknown
References <fd7e3315-6e8d-49dd-b741-b1ba2808f8ae@googlegroups.com>
Date 2015-10-26 11:30 -0600

Show all headers | View raw


On Monday, October 26, 2015 at 6:50:16 AM UTC-7, Kim Walisch wrote:
> Many system libraries offer a main header file in the root directory
> e.g. /usr/include which then includes a few other headers located
> inside a directory also installed in /usr/include. Below are a few
> examples from my Linux box:
> 
> /usr/include/ruby.h
> /usr/include/ruby
> 
> /usr/include/krb5.h
> /usr/include/krb5
> 
> /usr/include/lzma.h
> /usr/include/lzma
> 
> /usr/include/gssapi.h
> /usr/include/gssapi
> 
> Now if you look inside the headers above some include their other
> headers using <> while others use "", e.g.:
> 
> cat /usr/include/gssapi.h | grep include
> #include <gssapi/gssapi.h>
> 
> cat /usr/include/ruby.h | grep include
> #include "ruby/ruby.h"
> 
> The second version using "" seems more correct to me. I wonder if using
> <> might potentially cause issues when 2 versions of the library are
> installed e.g. one in /usr/include and another in /usr/local/include (
> will the header inside /usr/include reference its other headers inside
> /usr/local/include instead of /usr/include?).
> 
> So my question is: Are both (<> & "") uses safe or should one be
> preferred over the other?
> 

The only difference between the two is that when using "" the compiler will
first look for the include file in the local directory in which the
compilation command is executed, then if it is not found will continue to
search in the system-dependent standard include path (except, of course,
this is all after searching in any directories named with -I flags on the
command line)


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

Back to comp.lang.c++.moderated | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Include precedence <> vs "" for system libraries (Unix-like OSes) Kim Walisch <kim.walisch@googlemail.com> - 2015-10-26 08:42 -0600
  Re: Include precedence <> vs "" for system libraries (Unix-like OSes) FredK <fred.l.kleinschmidt@googlemail.com> - 2015-10-26 11:30 -0600
  Re: Include precedence <> vs "" for system libraries (Unix-like OSes) James Kuyper <jameskuyper@verizon.net> - 2015-10-26 15:39 -0600
    Re: Include precedence <> vs "" for system libraries (Unix-like OSes) marlow.agents@googlemail.com - 2015-11-04 06:56 -0600
  Re: Include precedence <> vs "" for system libraries (Unix-like  OSes) "James K. Lowden" <jklowden@speakeasy.net> - 2015-11-04 06:56 -0600

csiph-web