-
Notifications
You must be signed in to change notification settings - Fork 263
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
Macro redefinition error inside header stops whole compilation #140
Comments
Logs with -v=100 do not produce any meaningful errors. (ps I don't know what's the maximum level -v argument accepts) |
clang++ <rest of the command of .cpp with error> compiles successfully witho ut wanings and errors. |
You may also read #138 (comment) for some useful commands. Can you give some more information? e.g. if the file is a header or a normal C++ source, as https://github.com/MaskRay/ccls/wiki/FAQ#diagnostics-in-headers |
The error is in some deep nested boost header, there is macro redefinition (compile command contains -D for that macro). After this error takes place whole compilation stops. It looks like tthis: Some file included in file.cpp contains There seem to be no regressions, all ccls face this issue. Cqery handles it fine. BTW project build takes place inside docker |
Does |
Yes, it does. It makes ccls usable since clang doesn't stop on that error and compiles source that goes after. Is there a way to configure libclang to skip such errors and compile each file as much as it can? |
If your project uses You may try adding void BuildPreamble(CompletionSession &session, CompilerInvocation &CI,
...
// -Werror makes warnings issued as errors, which stops parsing
// prematurely because of -ferror-limit=. This also works around the issue
// of -Werror + -Wunused-parameter in interaction with SkipFunctionBodies.
auto &Ws = CI.getDiagnosticOpts().Warnings;
Ws.erase(std::remove(Ws.begin(), Ws.end(), "error"), Ws.end()); |
My project uses warnings intensively: |
index fab5daf7..cdd2ff32 100644
--- a/src/clang_complete.cc
+++ b/src/clang_complete.cc
@@ -318,6 +318,7 @@ void BuildPreamble(CompletionSession &session, CompilerInvocation &CI,
// prematurely because of -ferror-limit=. This also works around the issue
// of -Werror + -Wunused-parameter in interaction with SkipFunctionBodies.
auto &Ws = CI.getDiagnosticOpts().Warnings;
+ Ws.push_back("no-macro-redefined");
Ws.erase(std::remove(Ws.begin(), Ws.end(), "error"), Ws.end());
CI.getDiagnosticOpts().IgnoreWarnings = false;
CI.getFrontendOpts().SkipFunctionBodies = true; that didn't help, still get same error |
Can you take a look at https://github.com/llvm-mirror/clang/blob/master/test/Index/preamble.c and use
to check if libclang has the same issue? Please put all the pieces of information into one place. You can amend #140 (comment) |
I've created COMMAND and COMMAND2 files. First one contains compile command without first argument (g++). Second is the same as first but without -Werror.
by the end. |
% diagtool show-enabled -Wmost a.cc | grep mismatched-tag
W warn_struct_class_previous_tag_mismatch [-Wmismatched-tags]
W warn_struct_class_tag_mismatch [-Wmismatched-tags] You probably have The default |
Do these errors occur because of the logic of header parsing? (reduced number of header parsing) |
Yes.
Delete your |
UPD:
My project uses warnings intensively:
-Wall -Wextra -Werror=multichar -Wno-deprecated -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Werror -std=gnu++11 -Wno-unknown-pragmas.
I see macro redefinition error in many c++ files despite project compiles successfully. This error stops compilation on the point of error and autocompletion becomes too limited. The error is in some deep nested boost header, there is macro redefinition (compile command contains -D for that macro). After this error takes place whole compilation stops.
ORIGINAL COMMENT:
I switched from c3b4b7f to 1111, since I get a lot of warnings in my project:
The text was updated successfully, but these errors were encountered: