I installed a clangd plugin in VSCode to develop C++.
This plugin works well, but it shows some code error/waring in our project because we use a deprecated function in <zstd.h>.
include <zstd.h>
deprecated function
How can I mask this error without changing the code?
For example, I can ignore some warning in the VSCode's cpplint plugin by modifying .vscode/settings.json:
ignore some error on cpplint plugin
Can I do something like that to the VSCode's clangd plugin? thanks~
I try to use clang diagnostic, but it seems not work.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-attributes"
#include <zstd.h>
#pragma clang diagnostic pop
clang diagnostic don't work
First, note that the reason for the error is not the function being deprecated, it's a parsing error ("an attribute list cannot appear here"). The note related to deprecation is just a comment that shows up in the hover, unrelated to the error diagnostic.
If you'd like to suppress the error, you can do it using https://clangd.llvm.org/config.html#suppress. For example, you could create a .clangd file in your project root containing:
Diagnostics:
Suppress: attributes_not_allowed
(Note, attributes_not_allowed is the diagnostic code of the error from the first screenshot.)
However, suppressing the diagnostic is likely to just paper over an underlying problem that's likely related to your project's configuration. A better approach would be to fix the underlying issue. To do that, please review the project setup instructions and ensure your project has a compile_commands.json and clangd is finding it; if that doesn't resolve the issue, feel free to post clangd logs for further diagnosis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With