Hi, Will add second opinions to the warnings Simon reviewed. I mostly agree with him.
Simon Josefsson <[email protected]> writes: >> -Wunused-function > > I find this useful to find dead code. Likewise. >> -Winconsistent-dllimport > > Is that clang only? It seems enabled by default in clang. I haven't had to think about shared libraries much, so I am not sure about this one. >> -Wreserved-id-macro > > I recall fixing my code to respect this long time ago, so it seem > useful. I haven't seen this one, but seems useful to me as well. >> -Wundef > > I'm ignoring this warning in some projects, but for others it is useful > in non-gnulib code. I think that warns if you use '#if FOO' and FOO is not defined? I think that might cause problems in some projects. I would probably just ignore it. >> -Wmissing-field-initializers > > That has been a long source for pain for me, especially for test code. > In some projects I ignore it because fixing it results in ugly code. > > Is there any compilers that doesn't handle missing initializers > nowadays? Maybe the time has come to just ignore this globally, and > permit that usage. > > I suppose it is undefined if the field is initialized to NULL or not? I would have to pull up the C standard. But I recall seeing this warning with argp and just ignoring it. GCC and Clang handle it correctly at least. >> -Wunused-parameter > > I find this one useful. Likewise. It does get annoying if you have -Werror and are working on changes, though. But I usually just edit Makefiles by hand in that case. >> -Wgnu-include-next >> -Wimplicit-int-conversion >> -Wcomma >> -Wnonportable-system-include-path >> -Wtautological-unsigned-zero-compare >> -Wused-but-marked-unused >> -Wparentheses-equality >> -Wstring-plus-int > > I've not felt a need to ignore those, and the design philosophy of > manywarnings is to enable ALL possible warnings and then allow > maintainer to back out of things that they disagree with. > > We could provide some pre-defined set of warnings to ignore, for > maintainers who wish to opt-in and ignore entire sets of warnings, > perhaps? I guess the issue here is that sometimes we use the comma operator (well coreutils does, maybe Gnulib doesnt), which would trigger -Wcomma. Or write code that would trigger -Wstring-plus-int. Do we really want to change things just because Clang warns about it? I find that quite annoying to deal with. But I suppose it is better than adding pragmas to individual files. >> -Wsign-compare >> -Wsign-conversion >> -Wunused-macros >> -Wformat-nonliteral > > These can be nosiy, but also useful and I fix code for these. Likewise. I have mostly given up on -Wsign-compare, though. >> -Wdeprecated-declarations > > This seems useful to me. I don't mind this warning that much. I do find it annoying, though, when systems mark perfectly fine functions like sprintf deprecated. Even worse is OpenBSD which adds link warnings to what feels like half of their standard library. Collin
