Re:Breaking all the Eggs in C++ (2015)
by AlexanderDhoore on Sunday December 30, 2018 @12:02PM
(#18790060)
If everyone just runs a static analyzer after compiling you could have best of both worlds. For example the tool would complain if you don't use 'override'. Problem is that not everyone runs the same tool. So at work I would like to compile with (for example) -Wconversion (warn about implicit conversions that lose precision). But this is impossible because Qt headers raise so many warnings on this. And because C++ has no module system I can either 1) fix all of Qt or 2) don't add the warning and keep writing old C++. I think you can guess what I will do.
[ Parent
| on HN ]
Re:Breaking all the Eggs in C++ (2015)
by jcelerier on Sunday December 30, 2018 @12:14PM
(#18790125)
you can just include Qt with -isystem instead of -I, it will disable warnings for those headers
Re:Breaking all the Eggs in C++ (2015)
by hermitdev on Sunday December 30, 2018 @04:56PM
(#18791586)
Definitely recommend using -isystem for third party libs such as Boost, ACE, QT, Protobuf, etc. I strive for warning free code in my own, but dont have much control over the libs I use. Warnings from Protobuf are especially annoying due to Googles ill-thought-out disregard for signed/unsigned comparison (and their bullshit rationale in their style guideline) and continued use of NULL/0 as a nullptr constant (they only support C++11 and greater, no reason to not use nullptr now). I strive for clean compilation with "-Wall -Wextra -Wzero-as-null-pointer-constant -Werror", but alas, hard to implement after the fact in legacy code.
Re:Breaking all the Eggs in C++ (2015)
by AlexanderDhoore on Sunday December 30, 2018 @12:26PM
(#18790204)
Thx I will try this!
EDIT Docs about this: https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
I like your point.
Just to play with it a bit. Unenforced coding standards can't be relied on. So you want something like lint (of old), tidy-clang, or git check-in hooks to help enforce. At that point it becomes tempting to say "if it is part of the language, it should be in the compiler." But back to your point- it is easier for small groups to enforce their own standards than to change the compiler for everyone.
Re:Breaking all the Eggs in C++ (2015)
by ensiferum on Sunday December 30, 2018 @07:09PM
(#18792128)
I always make two header files with pragmas to disable compiler warnings and pops and then wrap any offending 3rd party header inclusions between those.
Or use clang-tidy and limit the analysis or filter the results to files under your control.
clang-tidy's for code cleanup. For serious static analysis, you need scan-build, which is dearly missing this functionality[1]. This is a serious issue for larger codebases with many external dependencies like LibreOffice.[2]
[1] https://bugs.llvm.org/show_bug.cgi?id=22594
[2] https://bugs.documentfoundation.org/show_bug.cgi?id=39596#c3...