-
Notifications
You must be signed in to change notification settings - Fork 346
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
Use Quoted Includes for Header-to-Header Inclusion #298
base: master
Are you sure you want to change the base?
Conversation
As I said in the other PR, the decision on whether to support an entirely different build system is up to @troldal - as for the includes, I will not touch them project-wide - I have broken things by changing some include logic in the past, this would require extensive testing to see if it makes sense. |
Thank you for the explanation. I’ll wait for @troldal’s comment.
There is an important difference. For example, if #include "b.h" and it will be resolved. On the other hand: #include <b.h> will only work if the directory is included in the compiler’s search paths. The key difference is that the former (using double quotes) guarantees resolution based solely on the library’s source tree structure, while the latter (using angle brackets) depends on the build configuration of the library user. This proposed change specifically focuses on addressing this distinction. |
I also once misunderstood the include preprocessor directive like you seemingly do. But that is not how it works: Check the
|
Fix your include path configuration and the error goes away. Specifically, in your setup, you did not completely replicate these include directories from
[..]
[..] |
Yes, that’s correct. If I can replicate the include path configuration that CMake sets up, I can build without modifying the codebase. Specifically, in this case, it’s necessary to add the
Unfortunately, due to the limitations of SwiftPM, it is not possible to replicate this. SwiftPM only allows setting one directory for a library’s public headers. |
In that case, this sounds like you should open a pull request / issue at https://github.com/swiftlang/swift-package-manager for supporting the functionality that every C++ compiler has. |
That’s one reasonable approach. |
It looks like your issue on the swift package manager is well received by at least one developer. Is it okay if you withdraw / close this pull request? |
No, setting aside the issue with SwiftPM, I’d like to hear @troldal’s opinion on the following matter: I believe the use of angle brackets for including It would be more desirable for the codebase to maintain consistency in this regard. This patch is unrelated to SwiftPM and represents a valuable improvement for the OpenXLSX codebase itself. |
This PR is part of an effort to support SwiftPM (#293), but to keep things organized, I am splitting it into smaller, focused changes. This particular PR addresses one such change: modifying how
XLXmlParser.hpp
includesXLException.hpp
by switching from angle brackets to quotes.This change is necessary for SwiftPM compatibility.
To provide some context, there are two types of builds to consider:
Building OpenXLSX itself: In this case, there is no issue.
OpenXLSX/
OpenXLSX/headers/
OpenXLSX/external/pugixml/
OpenXLSX/external/zippy/
XLCell.hpp
includes#include <pugixml.hpp>
.Building targets that use OpenXLSX: Here, SwiftPM's technical limitations introduce issues.
OpenXLSX/
allows the following includes:OpenXLSX/headers/
andOpenXLSX/external/pugixml/
are not included in the include paths.Luckily, this issue affects only the single location addressed by this patch. This is because, during the build of targets using OpenXLSX, headers are part of the compilation, but source files are not.
In the current codebase, pugixml includes are already written differently for headers and source files:
To address this, we need to fix how
XLXmlParser.hpp
includesXLException.hpp
. Both files are in the same directory, so using a quoted include resolves the path as a relative path:In fact, the following files already include
XLException.hpp
using quoted includes:XLXmlParser.hpp
is the only exception to this pattern, making it an outlier.