Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#include "" vs #include <> #36

Open
friendlyanon opened this issue Dec 17, 2021 · 1 comment
Open

#include "" vs #include <> #36

friendlyanon opened this issue Dec 17, 2021 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@friendlyanon
Copy link
Owner

#include <> will always look in directories the specified for the target or the system location(s), while #include "" will also look on the filesystem relative to the file before that.

This extra work incurs some cost, however the ability to group includes differently using clang-format is useful.

@friendlyanon friendlyanon added enhancement New feature or request question Further information is requested labels Dec 17, 2021
@SRNissen
Copy link

SRNissen commented Dec 3, 2023

#include <> will always look in directories the specified for the target or the system location(s), while #include "" will also look on the filesystem relative to the file before that.

Not quite

For <...>:

15.3.2

A preprocessing directive of the form

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

searches a sequence of implementation-defined places for...

And for "...":

15.3.3

A preprocessing directive of the form

# include " q-char-sequence " new-line

causes... [skip] ...searched for in an implementation-defined manner.

The only thing here that isn't implementation defined as such is that, if the implementation declines to implement 15.3.3, it is allowed to replace the quotation marks with angle brackets and just do a 15.3.2 search instead.

Which all really just goes to say: It really is up to the individual project what kind of #include style will work for their specific setup, so: Whether or not cmake-init advertises that it is opinionated, for this specific purpose, there is such a thing as a wrong opinion, and the wrong opinion is per-project, meaning it cannot be known ahead of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants