GNOME Bugzilla – Bug 483341
g_error and friends create warnings when not used in MSVC
Last modified: 2017-11-08 13:09:18 UTC
Please describe the problem: g_error and friends create warnings when not used in MSVC6. They are static functions and so when they are not used a warning is generated (a lot of noise). Putting these functions as inline solves the problem. And it also lets the compiler decides (according to the optimization rules size vs speed) wether to really inline the functions or make a code out of it. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Created attachment 96634 [details] [review] Fixes the warnings This code maybe be used in other (exotic) compilers. And the change should compile there too (inline is there anyway). The optimization should be done too according to what the compiler can do. But it will not make any existing code or binary not work.
(In reply to comment #1) > Created an attachment (id=96634) [edit] > Fixes the warnings inline is unfrotunately not usable everywhere, so this can't work without special treatment on every system. can you please add #include <glib/gutils.h> /* for 'inline' keyword */ to the start of your patched gmessage.h and see if that still works for you? this'd inline g_error and friends similar to g_string_append_c_inline() but unconditionally. which should be ok, since "inline" should be defined to "/**/" for compilers that cannot inline at all.
Created attachment 96647 [details] [review] New version with gutils.h included I added gutils just for the MSVC/exotic_compiler specific part of the code. That should limit the damages. And it does work in MSVC.
Review of attachment 96647 [details] [review]: ::: glib/gmessages.h @@ +156,3 @@ format) #else /* no varargs macros */ +#include <glib/gutils.h> /* for inline keyword */ This #include is no longer necessary. We require `static inline` support now: https://wiki.gnome.org/Projects/GLib/CompilerRequirements#Support_for_.27static_inline.27
I pushed a modified version of the patch, with a commit message I wrote (all mistakes mine).