git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org
Subject: Inline functions (Re: [PATCH/RFC v7 1/2] Add infrastructure for translating Git with gettext)
Date: Sat, 5 Jun 2010 15:16:53 -0500	[thread overview]
Message-ID: <20100605201652.GA5652@progeny.tock> (raw)
In-Reply-To: <AANLkTilRqVaVV5q-7NrserSDr0t4L1D_j8rNIWxtMYe1@mail.gmail.com>

Ævar Arnfjörð Bjarmason wrote:

> As an aside, I'd appreciate a document pointer, what are the
> implications here exactly?

Oh, good point!  I clean forgot to provide that.

"static inline" functions are just like macros, except each argument
is evaluated exactly once and the arguments are typechecked.

In the older dialect, what I was suggesting would be written as
follows:

 #ifdef NO_GETTEXT
 #define git_setup_gettext() do { } while(0)
 #else
 extern void git_setup_gettext(void);
 #endif

The feature has been part of GCC and various compilers for a long time
now.  It was finally officially adopted when the C99 standard came
out.  It "degrades gracefully" in that the Makefile will define inline
to nothing on those very old compilers known not to support it, making
these into static functions (which is kind of ugly but with most
optimizers it tends to produce the same result).

GCC documentation:

  http://gcc.gnu.org/onlinedocs/gcc/Inline.html

C99 documentation (see the "most current draft" of the revised C99
and navigate with PDF bookmarks to Language → Declarations →
Function specifiers → Semantics):

  http://www.open-std.org/jtc1/sc22/wg14/www/projects#9899

More important than all that is how the construct gets used and why.
For this, see SECTION 2 item 2 ("Ifdefs are ugly") of
linux-2.6/Documentation/SubmittingPatches[1]: and take a look at some
of the surrounding code (maybe include/linux/kernel.h would be
analogous) for examples.

Hope that helps,
Jonathan

[1] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/SubmittingPatches

  reply	other threads:[~2010-06-05 20:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-05  2:13 [PATCH/RFC v7 0/2] Add infrastructure for translating Git with gettext Ævar Arnfjörð Bjarmason
2010-06-05  2:13 ` [PATCH/RFC v7 1/2] " Ævar Arnfjörð Bjarmason
2010-06-05  2:57   ` Jonathan Nieder
2010-06-05  3:28     ` Ævar Arnfjörð Bjarmason
2010-06-05  3:36       ` Jonathan Nieder
2010-06-05 15:19         ` Ævar Arnfjörð Bjarmason
2010-06-05 19:27           ` Jonathan Nieder
2010-06-05 19:47             ` Ævar Arnfjörð Bjarmason
2010-06-12 17:26               ` Jonathan Nieder
2010-06-05  3:01   ` Jonathan Nieder
2010-06-05  3:30     ` Ævar Arnfjörð Bjarmason
2010-06-05  3:38       ` Jonathan Nieder
2010-06-05 14:10         ` Ævar Arnfjörð Bjarmason
2010-06-05 18:59           ` Jonathan Nieder
2010-06-05 19:33             ` Ævar Arnfjörð Bjarmason
2010-06-05 20:16               ` Jonathan Nieder [this message]
2010-06-05 13:57   ` Jakub Narebski
2010-06-05 16:19     ` Ævar Arnfjörð Bjarmason
2010-06-05  2:13 ` [PATCH/RFC v7 2/2] Add initial C, Shell and Perl gettext translations Ævar Arnfjörð Bjarmason

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20100605201652.GA5652@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).