Mercurial > hg > octave-kai > gnulib-hg
changeset 11906:6b25bda86ddb
Avoid sizeof __func__ == 0 pitfall.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 27 Aug 2009 23:30:11 +0200 |
parents | c80217bd6ec0 |
children | dffcdc89ae7e |
files | ChangeLog doc/func.texi tests/test-func.c |
diffstat | 3 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-27 Bruno Haible <bruno@clisp.org> + + * tests/test-func.c (main): Don't verify sizeof __func__ on SunPRO C + compilers. + * doc/func.texi: Document the SunPRO C bug. + 2009-08-27 Bruno Haible <bruno@clisp.org> Fix link error on Solaris.
--- a/doc/func.texi +++ b/doc/func.texi @@ -15,3 +15,6 @@ printf ("%s: hello world\n", __func__); @} @end smallexample + +Note that @code{sizeof} cannot be applied to @code{__func__}: On SunPRO C +compiler, @code{sizeof __func__} evaluates to 0.
--- a/tests/test-func.c +++ b/tests/test-func.c @@ -1,5 +1,5 @@ /* Test whether __func__ is available - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,13 @@ int main () { + ASSERT (strlen (__func__) > 0); + + /* On SunPRO C 5.9, sizeof __func__ evaluates to 0. The compiler warns: + "warning: null dimension: sizeof()". */ +#if !defined __SUNPRO_C ASSERT (strlen (__func__) + 1 == sizeof __func__); +#endif + return 0; }