All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Jonathan Corbet <corbet@lwn.net>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] CodingStyle: Add a chapter on conditional compilation
Date: Wed, 29 Oct 2014 19:24:11 -0700	[thread overview]
Message-ID: <20141030022411.GA28982@thin> (raw)
In-Reply-To: <545187B6.1090704@infradead.org>

On Wed, Oct 29, 2014 at 05:35:02PM -0700, Randy Dunlap wrote:
> On 10/29/14 12:12, Geert Uytterhoeven wrote:
> > On Wed, Oct 29, 2014 at 7:15 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> >> Document several common practices and conventions regarding conditional
> >> compilation, most notably the preference for ifdefs in headers rather
> >> than .c files.
> >>
> >> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> > 
> >> +If you have a function or variable which may potentially go unused in a
> >> +particular configuration, and the compiler would warn about its definition
> >> +going unused, mark the definition as __maybe_unused rather than wrapping it in
> >> +a preprocessor conditional.  (However, if a function or variable *always* goes
> >> +unused, delete it.)
> > 
> > Personally, I don't like __maybe_unused. Once it's there, the compiler
> > will stop warning about it, even if it really becomes unused.
> > 
> > Apart from that:
> > Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> 
> Is the compiler smart enough to delete (discard) the code or data instance
> if it is unused or is the code or data actually wasting space?

If you mark a function or variable as __maybe_unused, and it actually
goes unused, the compiler will silently discard it.

- Josh Triplett

  reply	other threads:[~2014-10-30  2:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 18:15 [PATCH] CodingStyle: Add a chapter on conditional compilation Josh Triplett
2014-10-29 19:12 ` Geert Uytterhoeven
2014-10-29 22:20   ` Josh Triplett
2014-10-30  0:35   ` Randy Dunlap
2014-10-30  2:24     ` Josh Triplett [this message]
2014-10-30  3:33 ` Martin Kelly
2014-11-03 16:46 ` Jonathan Corbet
2014-11-03 17:47   ` Joe Perches
2014-11-03 18:05     ` Josh Triplett
2014-11-03 18:39       ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141030022411.GA28982@thin \
    --to=josh@joshtriplett.org \
    --cc=corbet@lwn.net \
    --cc=geert@linux-m68k.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.