Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Warnings/Debugger Date: Tue, 18 Feb 2020 08:36:20 -0800 Organization: A noiseless patient Spider Lines: 67 Message-ID: <86pnebettn.fsf@linuxsc.com> References: <87v9onwoox.fsf@bsb.me.uk> <87tv45q01m.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="d9b0a35ddf05bf8591aa2d3738ff843a"; logging-data="26541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19L8yB/loBLM5BEULR4OnOG5ScQb1gcTnk=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:xAY/Ic3jwvsD74wxFokL947M9SI= sha1:tTOkhi3QW6Ct2bNoXa7oBZTHtqQ= Xref: csiph.com comp.lang.c:150072 Jorgen Grahn writes: > On Mon, 2020-02-10, Mehdi Amini wrote: > >> On 2/8/20 8:49 AM, James Kuyper wrote: > > ... > >>> Also, what was the 1 error message? >>> Just to give us an idea of what's going wrong, what was the very first >>> warning message? >> >> Compiler: >> -------------- Build: Release in Temp (compiler: LLVM Clang Compiler 10 >> GTK Library Warnings_Disabled)--------------- >> >> clang -pedantic -Weverything -Wall -std=c11 -pedantic -Weverything -Wall >> -std=c11 -m64 -w -std=c11 -pthread -I/usr/include/gtk-3.0 > > ... > >> #define __GTK_H__ >> ^ >> /usr/include/gtk-3.0/gtk/gtk.h:28:9: warning: macro name is a reserved >> identifier [-Wreserved-id-macro] > > You probably shouldn't use -Weverything. I never heard of it before, > but it seems to enable every warning anyone ever implemented, and > that's going to generate a lot of noise, like the warning quoted > above. Yes. I suppose there could be a situation where -Weverything is called for, but this isn't one of them. > [as to what options should be used,] > > -pedantic -Wall -Wextra -std=c11 > > is plenty, I recommend a more incremental approach. To start, compile with just -pedantic-errors (and also either -std=c11 or -std=c99, as may be preferred, but in any case an explicit choice). Most packages will clear this hurdle without any difficulty, but for those that don't it's good to get an early indication of that, to decide how to proceed further. After clearing the -pedantic hurdle, turn on individual warnings one or two at a time, in order of most serious type first. One way of doing this is to add temporarily -Wall and -Wextra, then look through the different kinds of warnings given, pick the most significant, and go back and add it to the list of specific warnings options (or perhaps not, if it is deemed not important enough). Repeat until the set of warning options converges. I have been following this method for fifteen or twenty years now, and find it gives better results than turning on all the warning options from the beginning. > and quality libraries are written so their header files > don't generate any of those warnings. That is true in many cases, but there are plenty of well-regarded libraries where using the -Wall/-Wextra options will generate some warnings. Also it is good to remember that -Wall/-Wextra is a moving target: software that clears the -Wall/-Wextra hurdle today may very well stumble tomorrow.