GNOME Bugzilla – Bug 99815
gstreamer should use ISO __VAR_ARGS__
Last modified: 2004-12-22 21:47:04 UTC
Because Gstreamer uses the GCC specific style of handling variable arguments in macros, gstreamer can only be compiled by gcc. Gstreamer header files should use the ISO standard for variable arguments (since the ISO standard is supported by both gcc and ISO standard compilers). #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__) Rather than the GCC specific style: #define debug(format, args...) fprintf (stderr, format, args) Note that the ISO standard does not support the "##" syntax to remove the extra comma if the variable arguments are omitted. So, for example, the GST_PROPS_LIST() in gst/gstprops.h and some macros in gst/gstinfo.h will need some extra attention. You can read more information about this here: http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Variadic-Macros.html#Variadic%20Macros
The following macros would need to be addressed to resolve this problem. There is only one macro that uses ## that would require anything more than trivial rework and that is GST_PROPS_LIST. GST_PROPS_LIST in gstprops.h Note: the above uses ## so will need to be reworked. I notice that there are only 18 references to this macro, all in testsuite/caps/compatibility.c, testsuite/caps/intersection.c, and testsuite/caps/normalization.c. All this macro is doing is the following: #define GST_PROPS_LIST(a...) GST_PROPS_LIST_TYPE,##a,NULL Which really isn't much. Therefore, the easiest thing to do would just be to simply get rid of this macro altogether and replace the macro references with what the macro is doing. The others are: GST_CAPS_NEW in gstcaps.h GST_CAPS_FACTORY in gstcaps.h gst_caps_set in gstcaps.h gst_caps_get in gstcaps.h (note for the above two, the ## could be eliminated as follows #define gst_caps_set(caps, ...) gst_props_set((caps)->properties, __VAR_ARGS__) GST_FORMATS_FUNCTION in gstformat.h GST_EVENT_MASK_FUNCTION in gstevent.h GST_PAD_QUERY_TYPE_FUNCTION in gstpad.h GST_PAD_TEMPLATE_NEW in gstpad.h GST_PAD_TEMPLATE_FACTORY in gstpad.h GST_SHOW_INFO in gstlog.h GST_DEBUG and GST_DEBUG_ELEMENT in gstinfo.h GST_INFO and GST_INFO_ELEMENT in gstinfo.h GST_ERROR and GST_ERROR_OBJECT in gstinfo.h Note: There's also some commented out convenience macros which would also be nice to support. Note: All the above gstlog.h and gstinfo.h macros use ##, but can easily be worked around as follows #define GST_DEBUG(cat, ...) G_STMT_START{ \ if ((1<<cat) & _gst_debug_categories) \ _gst_debug_handler(cat,_GST_DEBUG_INCORE,__FILE__, __PRETTY_FUNCTION__,__LINE__,_debug_string, \ NULL,g_strdup_printf( __VAR_ARGS__ )); \ }G_STMT_END Also gst/parse/parse.l has this problem on lines 8-12 8 #ifdef DEBUG 9 # define PRINT(a...) printf(##a) 10 #else 11 #define PRINT(a...) 12 #endif Note that this PRINT macro uses ##, but I think it is unnecessary since every single reference to PRINT has at least one argument passed in.
Created attachment 12622 [details] [review] patch that fixes many of the problems
I just attached a patch which corrects the ISO __VAR_ARGS__ issue and also fixes bug 89622. It also corrects the problem that __PRETTY_FUNCTION__ is not available on Solaris. I am still having problems compiling gstreamer on solaris with gst/gstinfo.c" generating a lot of errors like this: gstinfo.c", line 182: syntax error before or at: __attribute__ I'll look into this tomorrow, but I wanted to share the patch that I have created so far with people who could verify that it makes things work well on Linux as well.
Created attachment 12623 [details] [review] updated patch
I updated the patch to remove some debug cruft that shouldn't have been included there. Sorry.
Note that the only thing I think might be contentious about this patch is the change to gst/gst.c. Note I had to change this line: - const struct poptOption options_with[] = { + struct poptOption options_with[] = { The Forte compiler gets mad that we are trying to set a constant structure with a value passed in as a constant argument. The following line causes the compiler to barf: {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) popt_options, 0, "Application options:", NULL}, Removing the constant made the compiler stop complaining. However I suspect there might be a better way to do this.
ok, patch reviewed and approved by Erik Walthinsen. I will apply it to my local build tommorow and test. If it don't break anything I will commit. Thanks a lot Brian!
After applying patch on my local tree I now get: + running autoheader ... autoheader: missing template: HAVE_FUNC autoheader: missing template: HAVE_FUNCTION autoheader: missing template: HAVE_PRETTY_FUNCTION autoheader failed
Doh! I forgot to include the fact that you need to add an acconfig.h file to the toplevel directory of the gstreamer module. This file should just contain the following 3 lines, and the problem you are seeing will go away. Sorry about that. --acconfig.h starts below-- #undef HAVE_FUNC #undef HAVE_PRETTY_FUNCTION #undef HAVE_FUNCTION
I got another suggestion to change relevant section to (what is your opinion on this: AC_DEFINE(HAVE_FUNC,1,[defined if gcc have 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,1,[defined if gcc have 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,1,[defined if gcc have HAVE_FUNCTION)])
Yes, it looks like you are making the AC_DEFINE macros a bit nicer. I've tested your changes on Solaris and verified that it still works great. I think your change is good. By the way, do you have any idea how to address this issue that I'm still seeing? gstinfo.c", line 182: syntax error before or at: __attribute__ I notice that this website: http://www.redhat.com/mailing-lists/bochs-developers/msg00139.html seems to include the following patch in the source code to address a similar problem. I'm not really clear what this __attribute__ symbol is doing. Does this seem a reasonable solution for gstreamer as well? + /* gisburn 20010227: non-gcc compilers (like SUN Workshop 6) normally do not +have __attribute__ */ + #ifndef __GCC__ + #define __attribute__(x) + #endif +
ok, commited the updated patch with the marco changes to cvs just now. trying to get thomasvs to help us with this last issue :)
committed