public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Richard Knutsson <ricknu-0@student.ltu.se>,
	Mathieu Segaud <mathieu.segaud@regala.cx>,
	akpm@linux-foundation.org, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [Coding Style]: fs/ext{3,4}/ext{3,4}_jbd{,2}.c
Date: Sat, 5 Jan 2008 05:18:17 +0000	[thread overview]
Message-ID: <20080105051817.GD27894@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20080105041228.GP3351@webber.adilger.int>

On Fri, Jan 04, 2008 at 09:12:28PM -0700, Andreas Dilger wrote:

> What's wrong with __FUNCTION__?  I thought that was ANSI C?

__FUNCTION__ is a gccism of dubious taste - it pretends to be a macro
when it's something far out of scope of preprocessor.  Think for a minute
and you'll see why - you can't expand it until you are done with parsing.

__func__ is C99, but it's not what __FUNCTION__ used to be - it's not a
string literal.  6.4.2.2(1):

	The identifier __func__ shall be implicitly declared by the translator
as if, immediately following the opening brace of each function definition,
the declaration
	static const char __func__[] = "function-name";
appeared, where function-name is the name of the lexically-enclosing function.

IOW, it's a phase 7 (parsing and translation of translation units) and not
phase 4 (preprocessor).  Practical implications are:
	* _way_ fewer kludges
	* it happens after phase 6 (string literal concatenation)
So __FUNCION__ " is called" within body of foo() would result in
"foo is called" while __func__ "is called" is a syntax error.

These days old gcc __FUNCTION__ is gone; it's a macro expanding to __func__,
so behaviour does *not* match the original (see above).

The thing is, it's not something like __FILE__ or __LINE__ and never had been;
it tried to pretend that it had been like those but that required far too
nasty kludges and these days it is firmly in the "nothing to do with
preprocessor" land.  Old name is #defined to __func__ to approximate the
old behaviour, but it doesn't approximate it all that well and it's really
not fit for anything but backwards compatibility in legacy code.

BTW, we used to have code that broke when gcc abandoned the old kludge -
several years ago there'd been a pile of patches fixing the resulting
turds.

  parent reply	other threads:[~2008-01-05  5:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-04 13:21 [PATCH] [Coding Style]: misc fixes for fs/ext{3,4}/acl.{c,h} from checkpatch.pl Mathieu Segaud
2008-01-04 13:21 ` [PATCH] [Coding Style]: fs/ext{3,4}/balloc.c Mathieu Segaud
2008-01-04 13:21   ` [PATCH] [Coding Style]: fs/ext{3,4}/bitmap.c Mathieu Segaud
2008-01-04 13:21     ` [PATCH] [Coding Style]: fs/ext{3,4}/dir.c Mathieu Segaud
2008-01-04 13:21       ` [PATCH] [Coding Style]: fs/ext{3,4}/ext{3,4}_jbd{,2}.c Mathieu Segaud
2008-01-04 13:41         ` Richard Knutsson
2008-01-04 13:47           ` Mathieu SEGAUD
2008-01-05  4:12           ` Andreas Dilger
2008-01-05  4:47             ` Dmitri Vorobiev
2008-01-05  4:48             ` Dmitri Vorobiev
2008-01-05  5:18             ` Al Viro [this message]
2008-01-10 21:03               ` Roel Kluin
2008-01-11  3:09                 ` Peter Stuge
2008-01-11  3:42                   ` Paul Mundt
2008-01-11  3:46                     ` Peter Stuge
2008-01-11  9:45                     ` Roel Kluin
2008-01-11 10:29                       ` Paul Mundt
2008-01-11 11:04                         ` Roel Kluin
2008-01-11 11:23                           ` Paul Mundt
2008-01-11 12:27                             ` Roel Kluin
2008-01-04 13:44 ` [PATCH] [Coding Style]: misc fixes for fs/ext{3,4}/acl.{c,h} from checkpatch.pl Theodore Tso
2008-01-04 13:49   ` Mathieu SEGAUD
2008-01-04 13:56     ` Theodore Tso
2008-01-04 16:30   ` Andi Kleen
2008-01-04 19:01     ` Theodore Tso
2008-01-04 19:41       ` Andi Kleen
2008-01-04 20:01         ` Cyrill Gorcunov
2008-01-04 20:03         ` Paolo Ciarrocchi
2008-01-04 22:33           ` Andi Kleen
2008-01-05  0:12             ` Paolo Ciarrocchi
2008-01-05  0:39               ` Theodore Tso
2008-01-05 21:24                 ` Jan Engelhardt

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=20080105051817.GD27894@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.segaud@regala.cx \
    --cc=ricknu-0@student.ltu.se \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox