-
Notifications
You must be signed in to change notification settings - Fork 12
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
C++: hawkmoth warns about #pragma once in main file
#208
Comments
#pragma once in main file
#pragma once in main file
It does work for me, though. What's your platform and |
Also, what's the warning, exactly? If it can be reproduced on the |
On Debian Sid.
Interestingly, this does not appear when I run |
Oh? I only tested on the command-line, I'll need to try via the Sphinx extension. |
Looks like this is related to having Please either avoid doing that, or add
|
Nope, it definitely does for me when I use it via sphinx:
But I can confirm that renaming |
Okay, I can reproduce the behaviour, but I'm pretty confused why the result is different via CLI vs. Sphinx/pytest. It's reproducible also in the CLI test that gets run via pytest. I understand the warning, but not the difference. There's basically three ways to work around this:
Hawkmoth could identify headers and pass the |
If it this a clang issue, then I'm perfectly fine with adding |
Edit: this seams unrelated It seems to be a bit ore interesting than just pragma once. For example, this code: #include <exception>
#include <string>
namespace cnstln {
namespace CHIRP {
/**
* Error thrown when a Message was not decoded successfully
*/
class DecodeError : public std::exception {
public:
/**
* @param error_message Error message
*/
DecodeError(std::string error_message) : error_message_(std::move(error_message)) {}
/**
* @return Error message
*/
const char* what() const noexcept override { return error_message_.c_str(); }
protected:
/** The error message */
std::string error_message_;
};
}
} Produces no errors with the CLI, but gives
via sphinx (using #211, but the error is happens after |
I found the bug, it comes from this lines: hawkmoth/src/hawkmoth/__init__.py Line 58 in 92af8c2
I think this line can simply be removed, at least as far as my testing goes. |
Are you sure your libclang and its python bindings are of the same version? |
Agreed. |
FYI it looks like a C++20 bug in clang 16. |
By default, hawkmoth added the -xc++ compiler argument to clang, which caused issues with pragma only declaration (See jnikula#208). Changig this to -xc++-header solves this issue, while retaining compatibility with compiled units. Signed-off-by: Stephan Lachnit <[email protected]>
By default, hawkmoth added the -xc++ compiler argument to clang, which caused issues with pragma only declaration (See jnikula#208). Changig this to -xc++-header solves this issue, while retaining compatibility with compiled units. Signed-off-by: Stephan Lachnit <[email protected]>
Have a single point of truth for setting the clang -x<language> option, to unify parsing across the extension, tests, and cli. Choose the language primarily based on the domain, and secondarily based on the filename extension to differentiate headers. Using "-header" is necessary for some cases such as "#pragma once", where plain "-xc" or "-xc++" would interpret the file as a main file. This unconditionally bypasses libclang automatic detection. The user and tests can still override the parser selected language, as the user provided clang_args are appended. Fixes: #208
Okay, our |
Have a single point of truth for setting the clang -x<language> option, to unify parsing across the extension, tests, and cli. Choose the language primarily based on the domain, and secondarily based on the filename extension to differentiate headers. Using "-header" is necessary for some cases such as "#pragma once", where plain "-xc" or "-xc++" would interpret the file as a main file. This unconditionally bypasses libclang automatic detection. The user and tests can still override the parser selected language, as the user provided clang_args are appended. Fixes: #208
@stephanlachnit Many thanks for the report and debugging! There was more to this than met the eye at first. |
hawkmoth (or more likely, clang) warns about
#pragma once in main file
.To reproduce, try to add documentation for this file:
The warning has no impact on the output.
The text was updated successfully, but these errors were encountered: