-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 SYSTEM INTERFACE includes to suppress warnings (IDFGH-7212) #8806
Use SYSTEM INTERFACE includes to suppress warnings (IDFGH-7212) #8806
Conversation
Hello, can i ask why are you using |
@Barabas5532 Have you tried to specify additional warnings only for your project and not globally? I think developers usually do that in order to address your issue. If this is an acceptable solution then I would prefer it because it would avoid possible regressions for other developers projects. BTW, we are accepting PRs for the master branch only. We can later backport serious bugfixes but I don't think this is a candidate for that. |
This is useful in case the file including a header has more warnings enabled than the esp-idf default.
3df8e0c
to
2726e54
Compare
Using
I do not have any warning flags defined globally. The warnings I see in my build are from appearing while my files are being built, but are actually coming from a headers that were included from other components. You can see this in the snippet in the original description. The file being build is my source code at I have a component called The I think building all esp-idf examples and unit tests could be a good regression test. I assume you are doing this in CI already, if not, how could I build all of these easily on my machine? Maybe also need to check that things like deprecation warnings are still appearing. I've found some discussions about this topic and using https://stackoverflow.com/questions/1867065/how-to-suppress-gcc-warnings-from-library-headers |
@Barabas5532 The problem i see with this is that if there are things inside the component headers that generate legitimate warnings like types, functions and their content etc and you use those outside of the component itself, you will not get those warnings. Therefore something like this can be pretty dangerous. The source of the issue here and #8881 as well is the fact that every component is linked to the project_elf. We will look at this at a later date as it requires significant changes to the build system. |
@Barabas5532 We are currently working on a solution that involves fixing the root cause of both this and #8881 by linking all components as PRIVATE to the project_elf. This however is a breaking change and users using target_link_libraries in project-level CMakeLists (to add linker flags for example) or users with custom CMake projects that only include the esp-idf will have to specify PUBLIC, PRIVATE or INTERFACE as an argument to every target_link_libraries call aimed at project_elf. For this reason, we aim to fix this in ESP-IDF 5.0 and hope that you are able to switch to it when it releases. |
I'd like to set the SYSTEM property on all files that are included from the esp-idf path, so they are excluded by clang-tidy. After project(), can we set the SYSTEM property for certain targets or can we get the list of these include directories to include them again as SYSTEM, overwriting the previous include? I see that the list is generated in project(), but also unset again. |
I'm just testing out ESP-IDF 5.0 for C++20 support, and this issue is not fixed by the linked commit. I have created a repo for a minimal reproduction example here: https://github.com/Barabas5532/esp-idf-include-warnings-issue. I've just taken the The error produced with ESP-IDF at the
I don't think this is a problem, because the component will usually include its own header, and the warnings will show up there. For header only components, you can use a unit test or an empty source file in the same component that includes the header. For me, the benefit of more error checking at compile time is worth it, but maybe it's not a good default for all users. |
@Barabas5532 The linked issue adds these flags in the
Functions and macros inside of the component headers would have their warnings not emitted regardless of them being used in source files, which is rather dangerous. |
Apparently i was wrong about the cause of this, the reason for the failiure to build appears to be the fact that the function generating the failiure is inside of a header that gets included in This makes this less of an issue considering there are not many things in component headers from Espressif that can make builds fail, however it does make the issue harder to solve. |
We're not going to include component headers as SYSTEM because this provides valuable data from our customers, please report all failiures in separate issues and we will try to fix them by fixing the headers not to generate warnings instead of hiding them. |
GCC suppresses warnings coming from files included from the system path. This is documented here: https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
It is useful in case the file including a header from esp-idf has more warnings enabled than the esp-idf default.
I have an example of how this can go wrong in this build of my project: https://github.com/ShrapnelDSP/ShrapnelMonorepo/runs/6102273709?check_suite_focus=true
Here is a snippet for illustration. The warning is from
/opt/esp-idf/components/soc/include/soc/soc_memory_types.h
: