2

I'm trying to remove all clang-tidy warnings in my C++ project. But I get alternating modernize-deprecated-headers and misc-include-cleaner warnings.

For example: I use open_memstream in a file, so I include <cstdio>.This gives me the warning: no header providing "open_memstream" is directly included [misc-include-cleaner]

So instead I include <stdio.h>, but this gives me the warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead [modernize-deprecated-headers]

What should I do to remove both warnings. I don't want to filter out any warning.

7
  • One could argue that it is a clang-tidy bug that zmthere is no header that can be included for that function without any warning, but I think the real answer to tge question is, that there is no such function in C++ (only in C) and therefore it can not be used without problems. Commented Apr 3 at 8:59
  • You seem to be using a none std POSIX extension. This function is still under investigation for addition to ISO C: en.cppreference.com/w/c/experimental/dynamic . Moreover it is not a C++ std function. Therefore you need to replace the tag with C. Changing the extension of your TU to ".c" may help, by instructing tye compiler to compile as C rather than C++. Commented Apr 3 at 9:04
  • does your implementation defined std::open_memstream in <cstdio>? Commented Apr 3 at 9:04
  • The C++ alternatives might be stringstream or spanstream Commented Apr 3 at 9:12
  • 2
    Not all clang-tidy warnings make sense for all code. There's also the issue of possible false positives (and straight up bugs). I'd argue that one should, first of all, only enable the warnings that actually make sense for the given project and then also not be completely anal about removing all clang-tidy warnings everywhere. Fix what makes sense, sure, but be pragmatic about it. Commented Apr 3 at 9:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.