Relative include paths in headers #42
Labels
build issue
The issue describes the problem with the build
code health
Improve code readability, simplify maintenance and so on
Maintenance Challenges:
As the project grows and evolves, the directory structure may change. If there are numerous relative paths scattered throughout the codebase, we will need to update each occurrence whenever structural changes are made. This can be error-prone and time-consuming.
Readability and Maintainability:
Relative paths in include statements can make the codebase less readable and harder to maintain. They make it less clear where the included files are located in relation to the current source file, which can be confusing for both you and others who work on the code.
Non-standard Build Systems:
Considering the project is a library used as an external dependency by others, we need to keep in mind some build systems or development environments may not handle relative include paths well or may interpret them differently. This can lead to inconsistencies and issues when building the code in various contexts.
IDE and Tool Support:
Integrated development environments (IDEs) and code analysis tools may not handle relative paths effectively, potentially leading to incorrect code analysis or debugging.
User Perspective:
Considering the project is a library used as an external dependency, using relative paths has a higher chance of interfering with the user's codebase. Consider the following include path we have in the codebase:
../Utils/Logger.hpp
. Consider the project structure a user can have:If the user has a
./src/include
path specified and it goes earlier in the include path list than the one provided by the subproject, the user'sUtils/Logger.hpp
file could get included instead of our header.Other opinions:
Footnotes
https://softwareengineering.stackexchange.com/questions/407056/the-case-against-path-expressions-in-include-directives ↩
https://gist.github.com/DaveRandom/6830e379578a66e2c82593137e79d099#why-is-using-a-relative-path-generally-bad ↩
https://stackoverflow.com/a/5006955 ↩
The text was updated successfully, but these errors were encountered: