GNOME Bugzilla – Bug 758541
gstinfo: Fix ISO non-standard predefined identifier warning for __FUNCTION__ when compiled with gcc 5 -Wpedantic
Last modified: 2015-11-24 13:37:06 UTC
Created attachment 316094 [details] [review] Patch to address the issue. gstreamer 1.6.1, when compiled with gcc 5, produces a warning about non-standard identifier __FUNCTION__ use when used with -Wpedantic (which might turn into an error if compiled also with -Werror). C99 support is fully enabled with gcc 5 (without -std=c99 switch), therefore attached patch implements the first suggested solution as proposed in [1].
[1]: https://gcc.gnu.org/gcc-5/porting_to.html
Comment on attachment 316094 [details] [review] Patch to address the issue. > #ifndef GST_FUNCTION > #if defined (__GNUC__) || (defined (_MSC_VER) && _MSC_VER >= 1300) >-# define GST_FUNCTION ((const char*) (__FUNCTION__)) >+# if __GNUC__ < 5 >+# define GST_FUNCTION ((const char*) (__FUNCTION__)) >+# else >+# define GST_FUNCTION ((const char*) (__func__)) >+# endif > #elif defined (__STDC__) && defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L > # define GST_FUNCTION ((const char*) (__func__)) > #else I wonder if moving up the #elif defined (__STDC__) && defined (__STDC_VERSION__) && would also fix this issue?
Possibly. Intention was to keep the change 'minimal', i.e. it introduces a change only for gcc 5 builds - indeed moving _STDC_ up would work - and might be more appropriate.
Could you try please? :)
Sure, I am going to - just need a couple of hours more to get home to be able to do that - I was going to post the result once finished.
Created attachment 316146 [details] [review] Updated patch to address the issue
Thanks for the patch, pushed (reworded the commit message a little to point out the -Wpedantic aspect of it): commit 7e2aae7942f4232ee7a9e84c52d265b722890da3 Author: Lukasz Forynski <lukasz.forynski@youview.com> Date: Mon Nov 23 21:40:34 2015 +0000 info: fix compiler warning with -Wpedantic and gcc 5 Gstreamer compiled with gcc 5.2 and -Wpedantic produces the following warning: 'ISO C does not support '__FUNCTION__' predefined identifier [-Wpedantic] const char *s = __FUNCTION__;' Since gcc 5 enables C99 by default, use __func__ if it's available instead of the non-standard __FUNCTION__ (as suggested in [2]). [1]: https://gcc.gnu.org/gcc-5/changes.html [2]: https://gcc.gnu.org/gcc-5/porting_to.html https://bugzilla.gnome.org/show_bug.cgi?id=758541
Thanks Tim-Philipp