PATCH: __FUNCTION__ vs. __func__
- From: Ali Akcaagac <ali akcaagac stud fh-wilhelmshaven de>
- To: balsa-list gnome org
- Subject: PATCH: __FUNCTION__ vs. __func__
- Date: 22 Jan 2002 20:03:56 +0100
hello,
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.
well i asked in #gnome about this and got pointed to glib but that
was'nt what i actually needed since we use -Werror and it should'nt
abort. then i searched in google about other people reporting this sort
of information and found something that helped me to offer at least this
solution.
what does this patch do:
a) it adds some sumbroutines to configure.in which checks in this row:
do we have funct (yes/no)
if yes, export variable
if no
do we have pretty function (yes/no)
if yes, export variable
if no
do we have function (yes/no)
if yes, export variable
if no (should'nt happen)
b) adds the declaraions to acconfig.h
c) src/sendmail-window.c
added three different ifdefs so we always get the right code.
i added pretty_function because i belive that pretty function outputs
more information than function. now what i like is that someone is going
to apply this to the current CVS checkout and test it with gcc2.9.x and
report how the results are. i know that on other unix systems a lot of
compilers does'nt support __FUNCTION__ but __func__ so if this works
then i bet we can offer balsa to a more wide userbase.
--
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 Tue Jan 22 19:49:48 2002
+++ balsa/acconfig.h Tue Jan 22 19:49:44 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 Tue Jan 22 19:49:48 2002
+++ balsa/configure.in Tue Jan 22 19:49:45 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 Tue Jan 22 19:49:51 2002
+++ balsa/src/sendmsg-window.c Tue Jan 22 19:49:47 2002
@@ -1110,6 +1110,61 @@
NULL, NULL, NULL, NULL, event->button, event->time);
}
+#ifdef HAVE_FUNC
+static void
+destroy_attachment (gpointer data)
+{
+ attachment_t *attach = (attachment_t *)data;
+
+ /* unlink the file if necessary */
+ if (attach->delete_on_destroy) {
+ char *last_slash = strrchr(attach->filename, '/');
+
+ if (balsa_app.debug)
+ fprintf (stderr, __FILE__ ":" __func__ ": unlink `%s'\n",
+ attach->filename);
+ unlink(attach->filename);
+ *last_slash = 0;
+ if (balsa_app.debug)
+ fprintf (stderr, __FILE__ ":" __func__ ": rmdir `%s'\n",
+ attach->filename);
+ rmdir(attach->filename);
+ }
+ /* clean up memory */
+ g_free(attach->filename);
+ g_free(attach->force_mime_type);
+ g_free(attach);
+}
+#endif /* HAVE_FUNC */
+
+#ifdef HAVE_PRETTY_FUNCTION
+static void
+destroy_attachment (gpointer data)
+{
+ attachment_t *attach = (attachment_t *)data;
+
+ /* unlink the file if necessary */
+ if (attach->delete_on_destroy) {
+ char *last_slash = strrchr(attach->filename, '/');
+
+ if (balsa_app.debug)
+ fprintf (stderr, __FILE__ ":" __PRETTY_FUNCTION__ ": unlink `%s'\n",
+ attach->filename);
+ unlink(attach->filename);
+ *last_slash = 0;
+ if (balsa_app.debug)
+ fprintf (stderr, __FILE__ ":" __PRETTY_FUNCTION__ ": rmdir `%s'\n",
+ attach->filename);
+ rmdir(attach->filename);
+ }
+ /* clean up memory */
+ g_free(attach->filename);
+ g_free(attach->force_mime_type);
+ g_free(attach);
+}
+#endif /* HAVE_PRETTY_FUNCTION */
+
+#ifdef HAVE_FUNCTION
static void
destroy_attachment (gpointer data)
{
@@ -1134,6 +1189,7 @@
g_free(attach->force_mime_type);
g_free(attach);
}
+#endif /* HAVE_FUNCTION */
/* add_attachment:
adds given filename to the list.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]