Re: many packages __FUNCTION__ problems



On Mon, 2002-01-28 at 23:43, Owen Taylor wrote:
> If code deals with __FUNCTION__ directly, it should just be patched in the mode:
> 
>  sprintf (__FUNCTION__ ": An error occurred);
> 
> Goes to:
> 
>  sprintf ("%s: An error occurred, __FUNCTION__);
> 
> No configure checks necessary.

no, sorry... well in your case here this might be right at least
the way you explain it.

... but __FUNCTION__ doesn't exist anymore (sooner or later). no matter
how you include __FUNCTION__ the compiler always hit an ERROR.

another example:

in balsa we use the function call as you describe

>  sprintf ("%s: An error occurred, __FUNCTION__);

same situation. it hits an error, since it searches for __FUNCTION__

look at the attachment balsa5.txt and the balsa-function2.patch it's
basically the same stuff i've sent here but in this situation we needed
to patch the sprintf. a lot of __FUNCTION__ calls within galeon-nautilus
view. around 10-5 direct function calls made in the sprintf way.

it can't deal with __FUNCTION__ & -Werror correctly. if you don't use
-Werror, then the compiler hit this warning but continue to compile
things correctly.

now the correct solution is:

a) we have a gnu compiler.. but the gnu compiler throw an error when we
   use the __FUNCTION__ call so it's not necesarryly clear if we assume
   that the gnu compiler uses (or still uses __FUNCTION__)
b) implement a check (with a little codefragement) to check from best to
   worst case

   best: compiler supports __func__ (no matter if gnu or not)
   midd: compiler supports __PRETTY_FUNCTION_
   wors: compiler supports __FUNCTION__

but ok, you can handle this in glib as you wish. my previous email was
most meant for people that directly implement __FUNCTION__ in their
code. i recommend installing a gcc3.0.3 testsuite on a new partition.
get some code that deal with this and compile with output redirected to
an file and then read the file afterwards.

-- 
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali akcaagac stud fh-wilhelmshaven de
WWW.....: http://www.fh-wilhelmshaven.de/~akcaagaa
diff -ruN balsa-cvs/acconfig.h balsa/acconfig.h
--- balsa-cvs/acconfig.h	Wed Jan 23 10:36:42 2002
+++ balsa/acconfig.h	Wed Jan 23 10:36:39 2002
@@ -12,6 +12,9 @@
 #undef HAVE_SIGSET_H
 #undef HAVE_GTKHTML
 #undef HAVE_GNOME_PRINT
+#undef HAVE_FUNC
+#undef HAVE_PRETTY_FUNCTION
+#undef HAVE_FUNCTION
 #undef BALSA_MAJOR
 #undef BALSA_PATCHLEVEL
 #undef BALSA_REVISION
diff -ruN balsa-cvs/configure.in balsa/configure.in
--- balsa-cvs/configure.in	Wed Jan 23 10:36:42 2002
+++ balsa/configure.in	Wed Jan 23 10:36:39 2002
@@ -614,6 +614,40 @@
 fi
 
 dnl ##########################################################################
+dnl Check for functions.
+dnl ##########################################################################
+
+AC_MSG_CHECKING(whether $GCC implements __func__)
+AC_CACHE_VAL(have_func,
+[AC_TRY_LINK([#include <stdio.h>],[printf("%s", __func__);],
+have_func=yes,
+have_func=no)])
+AC_MSG_RESULT($have_func)
+if test "$have_func" = yes; then
+	AC_DEFINE(HAVE_FUNC)
+else
+	AC_MSG_CHECKING(whether $GCC implements __PRETTY_FUNCTION__)
+	AC_CACHE_VAL(have_pretty_function,
+	[AC_TRY_LINK([#include <stdio.h>],[printf("%s", __PRETTY_FUNCTION__);],
+	have_pretty_function=yes,
+	have_pretty_function=no)])
+	AC_MSG_RESULT($have_pretty_function)
+	if test "$have_pretty_function" = yes; then
+		AC_DEFINE(HAVE_PRETTY_FUNCTION)
+	else
+		AC_MSG_CHECKING(whether $GCC implements __FUNCTION__)
+		AC_CACHE_VAL(have_function,
+		[AC_TRY_LINK([#include <stdio.h>],[printf("%s", __FUNCTION__);],
+		have_function=yes,
+		have_function=no)])
+		AC_MSG_RESULT($have_function)
+		if test "$have_function" = yes; then
+			AC_DEFINE(HAVE_FUNCTION)
+		fi
+	fi
+fi
+
+dnl ##########################################################################
 dnl Create files.
 dnl ##########################################################################
 
diff -ruN balsa-cvs/src/sendmsg-window.c balsa/src/sendmsg-window.c
--- balsa-cvs/src/sendmsg-window.c	Wed Jan 23 10:36:45 2002
+++ balsa/src/sendmsg-window.c	Wed Jan 23 10:36:41 2002
@@ -1110,6 +1110,16 @@
 		       NULL, NULL, NULL, NULL, event->button, event->time);
 }
 
+#ifdef HAVE_FUNC
+#define FUNCTION __func__
+#elif HAVE_PRETTY_FUNCTION
+#define FUNCTION __PRETTY_FUNCTION__
+#elif HAVE_FUNCTION
+#define FUNCTION __FUNCTION__
+#else
+#define FUNCTION ""
+#endif
+
 static void
 destroy_attachment (gpointer data)
 {
@@ -1120,12 +1130,12 @@
 	char *last_slash = strrchr(attach->filename, '/');
 
 	if (balsa_app.debug)
-	    fprintf (stderr, __FILE__ ":" __FUNCTION__ ": unlink `%s'\n",
+	    fprintf (stderr, __FILE__ ":" FUNCTION ": unlink `%s'\n",
 		     attach->filename);
 	unlink(attach->filename);
 	*last_slash = 0;
 	if (balsa_app.debug)
-	    fprintf (stderr, __FILE__ ":" __FUNCTION__ ": rmdir `%s'\n",
+	    fprintf (stderr, __FILE__ ":" FUNCTION ": rmdir `%s'\n",
 		     attach->filename);
 	rmdir(attach->filename);
     }
make  all-recursive
make[1]: Entering directory `/tmp/balsa'
Making all in macros
make[2]: Entering directory `/tmp/balsa/macros'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/balsa/macros'
Making all in po
make[2]: Entering directory `/tmp/balsa/po'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/balsa/po'
Making all in sounds
make[2]: Entering directory `/tmp/balsa/sounds'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/balsa/sounds'
Making all in images
make[2]: Entering directory `/tmp/balsa/images'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/balsa/images'
Making all in intl
make[2]: Entering directory `/tmp/balsa/intl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/balsa/intl'
Making all in help
make[2]: Entering directory `/tmp/balsa/help'
Making all in C
make[3]: Entering directory `/tmp/balsa/help/C'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/tmp/balsa/help/C'
make[3]: Entering directory `/tmp/balsa/help'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/tmp/balsa/help'
make[2]: Leaving directory `/tmp/balsa/help'
Making all in libmutt
make[2]: Entering directory `/tmp/balsa/libmutt'
make  all-recursive
make[3]: Entering directory `/tmp/balsa/libmutt'
Making all in imap
make[4]: Entering directory `/tmp/balsa/libmutt/imap'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/tmp/balsa/libmutt/imap'
make[4]: Entering directory `/tmp/balsa/libmutt'
make[4]: Leaving directory `/tmp/balsa/libmutt'
make[3]: Leaving directory `/tmp/balsa/libmutt'
make[2]: Leaving directory `/tmp/balsa/libmutt'
Making all in libbalsa
make[2]: Entering directory `/tmp/balsa/libbalsa'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/balsa/libbalsa'
Making all in libinit_balsa
make[2]: Entering directory `/tmp/balsa/libinit_balsa'
make  all-am
make[3]: Entering directory `/tmp/balsa/libinit_balsa'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/tmp/balsa/libinit_balsa'
make[2]: Leaving directory `/tmp/balsa/libinit_balsa'
Making all in src
make[2]: Entering directory `/tmp/balsa/src'
source='sendmsg-window.c' object='sendmsg-window.o' libtool=no \
depfile='.deps/sendmsg-window.Po' tmpdepfile='.deps/sendmsg-window.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I.. -DGNOMELOCALEDIR=\""/usr/local/share/locale"\" -I.. -I../libbalsa  -I/usr/local/include/gtk-1.2 -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include -I/usr/X11R6/include  -g -O2 -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include -D_REENTRANT -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include -I/usr/local/include/gtk-1.2 -I/usr/X11R6/include -I/usr/local/include/gnome-1.0 -DNEED_GNOMESUPPORT_H -I/usr/local/lib/gnome-libs/include -I/usr/X11R6/include/freetype2 -I/usr/local/include/gdk-pixbuf-1.0 -I/usr/local/include/gnome-xml -I/usr/local/include/gnome-vfs-1.0 -I/usr/local/lib/gnome-vfs-1.0/include -I/usr/local/include -I/usr/local/include/orbit-1.0 -I/usr/local/include/gconf/1 -D_REENTRANT -I/usr/local/include/libglade-1.0 -Werror -c `test -f sendmsg-window.c || echo './'`sendmsg-window.c
cc1: warnings being treated as errors
sendmsg-window.c: In function `destroy_attachment':
sendmsg-window.c:1123: warning: concatenation of string literals with __FUNCTION__ is deprecated.  This feature will be removed in future
sendmsg-window.c:1128: warning: concatenation of string literals with __FUNCTION__ is deprecated.  This feature will be removed in future
make[2]: *** [sendmsg-window.o] Error 1
make[2]: Leaving directory `/tmp/balsa/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/balsa'
make: *** [all] Error 2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]