Code Monkey home page Code Monkey logo

Comments (8)

sapek avatar sapek commented on August 14, 2024

#include with double quotes are used intentionally when we are including a file from the same directory or a path relative to it. This is the case for the example you linked.

If you find a case where there is an double-quote #include and file is included from the include path, please do send a pull request.

from bond.

elfring avatar elfring commented on August 14, 2024

I assumed that the referenced header file belongs to your public application programming interface, doesn't it?

from bond.

sapek avatar sapek commented on August 14, 2024

Yes. When you include it in your program you should include it as following (that's what the examples do):

#include <bond/core/apply.h>

But when we include it from another header in bond/core we use #include "apply.h". In part that is a convention but this is also the most unambiguous way to include it: #include <bond/core/apply.h> could be "hijacked" by the user of Bond, either by accident or on purpose, by putting another file with that name in front of include path.

from bond.

elfring avatar elfring commented on August 14, 2024

It seems that I do not really understand the purpose for your kind of distinction around such API header usage so far.

from bond.

sapek avatar sapek commented on August 14, 2024

The distinction is not based on whether header is API or not but where it should be included from: the same directory or include path.

What advantage do you see in looking for such headers in the include path first? Either preprocessor will find the file in the same directory (which is what #include with quotes will always do) or it will find another file, in which case it will be wrong.

from bond.

elfring avatar elfring commented on August 14, 2024

I suggest to reconsider the consequences of the following wording from the section "16.2 Source file inclusion" in the standard specification for the programming language "C++".

…
The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read

#include <h-char-sequence> new-line
…

from bond.

sapek avatar sapek commented on August 14, 2024

I'm going to close the issue as won't fix and I think we are over-analyzing it. Both conventions are plausible and different libraries use them. But since you are quoting the standard I want to point out that the standard actually has even more hardcore recommendation against using the < > form than the convention we adopted. The standard recommends that the < > form should be used only for header files provided by the implementation (i.e. the standard library), see the note 7 in section 16.2 Source file inclusion of C++11 standard:

[Note: Although an implementation may provide a mechanism for making arbitrary source files 
available to the < > search, in general programmers should use the < > form for headers provided 
with the implementa-tion, and the " " form for sources outside the control of the implementation. 
For instance:
#include <stdio.h>
#include <unistd.h>
#include "usefullib.h"
#include "myprog.h"
—end note]

from bond.

elfring avatar elfring commented on August 14, 2024

There are different opinions about the handling of the involved implementation-defined behaviour.

  • Will header files be also searched outside the specified include directories if double quotes are used for the discussed preprocessor statement?
  • Is there a speed difference measurable if a file is not found there and the search will be retried with "the angle brackets inclusion method"?

from bond.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.