Skip to content

Conversation

@JohnC32
Copy link

@JohnC32 JohnC32 commented Apr 18, 2025

The Prefer the quoted form of #include for files relative to the including file and the angle bracket form everywhere else is nice. This pull request is to clarify what relative path is, which then makes it very easy to enforce:

  • Add and example clarifying that #include "utilities.hpp" or #include "../module1/utilities.hpp" can resolve to same file and are both relative.

  • With this clarification, enforcement becomes very easy because compilers can report the absolute path of the file being reference.

…suggestion

- Add and example clarifying that #include "utilities.hpp" or #include "../module1/utilities.hpp"
  can resolve to same file and are both relative.

- With this clarification, enforcement becomes very easy because compilers can report the absolute
  path of the file being reference.

##### Project Example

Consider a project with modules where src/module2/foo.cpp is using src/module1/utilities.hpp:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you're referring to the C++ language feature 'modules', so this is a poor choice of wording.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I updated it to use the more generic term component (a modular, self-contained unit of software that encapsulates specific functionality). Components may be built into .so/.dll's and linked or loaded by the main executable. Alternatively, all sources of multiple components can be compiled into one executable. Should I a definition of component to be super clear, or is the term component enough?

@hsutter
Copy link
Contributor

hsutter commented May 8, 2025

Editors call: The Guidelines are focused on trying to encourage a set of best practices, and so can't bless all potentially reasonable practices. In this case, we don't want to encourage relative paths, especially with ../ navigation, in #include in the source file, we feel they are better done on the command line.

@hsutter hsutter closed this May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants