Re: PATCH: __FUNCTION__ vs. __func__



On Tue, 2002-01-22 at 20:03, Ali Akcaagac wrote:
> oki as you know development goes on, so is gcc 3.0.3 going on and balsa
> unfortunately causes -Werror abort on __FUNCTION__ since it is marked as
> depracted in 3.0.3 now i offered some solutions the previous days but
> none of them is backport compatible (dunno why this maybe __func__) is
> not supported in gcc below 3.0. at least i can't verify this for my own
> since i don't have 2.9.x anymore.

oki here another version with cleaner src/sendmsg-window.c part :)

-- 
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);
     }


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