Skip to content

SF.12 is ambiguous when a library uses a unique include subfolder #1980

Open
@eyalroz

Description

@eyalroz

(See also this SO question.)

Rule SF.12 says we should

use the quoted form for including files that exist at a relative path ...

because:

This encourages being clear about the locality of the file...

and

It makes it easy to understand at a glance whether a header is being included from a local relative file versus a standard library header or a header from the alternate search path (e.g. a header from another library or a common set of includes).

but - what about the case where locality is clear, because the library uses a unique include subfolder? e.g. #include <my_lib/some_file.hpp>? In fact, in this case, another, more specific part of SF.12 seems to apply:

Library creators should put their headers in a folder and have clients include those files using the relative path #include <some_library/common.h>

as a library's include file is also a "client" of the library's (other) include files.

It is also worth mentioning that the Boost libraries seem to prefer angle-brackets for files known to be accessible via relative paths.

So, I suggest one of two things:

  1. Amend the general rule to exclude the case of a library-specific include subfolder/prefix.
  2. Clarify that, within a library's include files, one should prefer quoted include paths

I'm a bit partial to (1.) - it's my personal style so far - but don't have a strong opinion.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions