[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: __func__
From: |
Simon Josefsson |
Subject: |
Re: __func__ |
Date: |
Thu, 06 Mar 2008 11:17:01 +0100 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) |
Eric Blake <address@hidden> writes:
> According to Simon Josefsson on 3/4/2008 7:39 AM:
> |
> | However, what do you think about this?
> |
> | /Simon
> |
> |>From 232f8a7255f8addd9724156d7d245b51a7feb72e Mon Sep 17 00:00:00 2001
> | From: Simon Josefsson <address@hidden>
> | Date: Tue, 4 Mar 2008 15:37:59 +0100
> | Subject: [PATCH] Add module __func__ to provide C99 __func__ variable.
> |
> | ---
> | doc/gnulib.texi | 14 ++++++++++++++
> | m4/__func__.m4 | 20 ++++++++++++++++++++
> | modules/__func__ | 20 ++++++++++++++++++++
>
> Maybe it's just me, but I hate typing _ (it involves a shift key and some
> coordination). Can we name it modules/func rather than modules/__func__?
Ouch, I have already pushed it. Should we rename it?
> | address@hidden __func__
> | address@hidden __func__
> | +
> | +The @code{__func__} module makes sure that you can use the
> | address@hidden variable as defined by C99 in your code.
>
> Should we use the C99 terminology, where __func__ is predefined
> identifier? Technically, since it is const and not an lvalue, the term
> variable is a bit misleading.
I agree.
> | +
> | +A small example is:
> | +
> | address@hidden
> | +#include <config.h>
>
> #include <stdio.h> /* for printf */
Yep.
> | +...
> | +printf ("%s: something happened\n", __func__);
> | address@hidden smallexample
>
> Include a function declaration around the use of __func__ in your example,
> since using __func__ outside a function is undefined.
I added a main function.
> | + ASSERT (strlen (__func__) + 1 == sizeof (__func__));
>
> The () around __func__ are extraneous.
Thanks. I have pushed the patch below.
/Simon
>From e2b0fa9ef05ff15dba4f7051e8eede3a27b80589 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Thu, 6 Mar 2008 11:16:06 +0100
Subject: [PATCH] Minor cleanups of __func__ module, suggested by Eric Blake
<address@hidden>.
---
ChangeLog | 9 +++++++++
doc/gnulib.texi | 12 ++++++++----
tests/test-__func__.c | 2 +-
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7b9fa02..16caed6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-03-06 Simon Josefsson <address@hidden>
+
+ * doc/gnulib.texi (__func__): Use C99 terminology when talking
+ about __func__. Make example self-contained. Suggested by Eric
+ Blake <address@hidden>.
+
+ * tests/test-__func__.c (main): Avoid extraneous () around __func.
+ Suggested by Eric Blake <address@hidden>.
+
2008-03-05 Simon Josefsson <address@hidden>
* modules/byteswap (License): Re-license as LGPLv2+.
diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index 31f51df..8de6d8e 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -5829,15 +5829,19 @@ generated automatically.
@node __func__
@section __func__
-The @code{__func__} module makes sure that you can use the
address@hidden variable as defined by C99 in your code.
+The @code{__func__} module makes sure that you can use the predefined
+identifier @code{__func__} as defined by C99 in your code.
A small example is:
@smallexample
#include <config.h>
-...
-printf ("%s: something happened\n", __func__);
+#include <stdio.h> /* for printf */
+
+int main (void)
address@hidden
+ printf ("%s: hello world\n", __func__);
address@hidden
@end smallexample
@node GNU Free Documentation License
diff --git a/tests/test-__func__.c b/tests/test-__func__.c
index afa6159..7b49026 100644
--- a/tests/test-__func__.c
+++ b/tests/test-__func__.c
@@ -36,6 +36,6 @@
int
main ()
{
- ASSERT (strlen (__func__) + 1 == sizeof (__func__));
+ ASSERT (strlen (__func__) + 1 == sizeof __func__);
return 0;
}
--
1.5.4.1
- Re: __func__, Simon Josefsson, 2008/03/03
- Re: __func__, Bruno Haible, 2008/03/03
- Re: __func__, Simon Josefsson, 2008/03/04
- Re: __func__, Bruno Haible, 2008/03/04
- Re: __func__, Simon Josefsson, 2008/03/06
- Re: AC_COMPILE_IFELSE, Bruno Haible, 2008/03/06
- Re: AC_COMPILE_IFELSE, Ralf Wildenhues, 2008/03/06
- Re: AC_COMPILE_IFELSE, Bruno Haible, 2008/03/06
- Re: AC_COMPILE_IFELSE, Eric Blake, 2008/03/06
- Re: __func__, Eric Blake, 2008/03/04
- Re: __func__,
Simon Josefsson <=
- Re: __func__, Jim Meyering, 2008/03/06
- Re: __func__, Simon Josefsson, 2008/03/06
- Re: __func__, Simon Josefsson, 2008/03/06
- Re: __func__, Bruno Haible, 2008/03/06