Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Intentionally unused variable, suppress warnings for just one? Date: Tue, 02 Aug 2016 14:47:18 -0700 Organization: None to speak of Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="27013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WDMKt6cgdt55e/gMdpyGi" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:FrN8VL+eFZHyL4076VZlRxyITBk= sha1:e7fKderDQt6pa7tnLSxq/5qIcFs= Xref: csiph.com comp.lang.c:91584 mathog writes: > This is probably off topic, but somebody here is likely to know how to > do this, so... > > In some code there is a function: > > SOME_STRUCTURE_TYPE a_structure; > int a_result = a_function(&a_structure); > > where "a_result" is never referred to again in the rest of the code. [reasons snipped] > What I want to do is suppress the warning only for these 10 lines. This seems to work for gcc, and may work for other compilers as well: SOME_STRUCTURE_TYPE a_structure; int a_result = a_function(&a_structure); (void)a_result; (I might wonder whether you really should be ignoring the result, but there's not enough information to speculate.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"