After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 483341 - g_error and friends create warnings when not used in MSVC
g_error and friends create warnings when not used in MSVC
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.14.x
Other All
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2007-10-04 12:58 UTC by Steve Lhomme
Modified: 2017-11-08 13:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fixes the warnings (1.14 KB, patch)
2007-10-04 13:00 UTC, Steve Lhomme
rejected Details | Review
New version with gutils.h included (1.19 KB, patch)
2007-10-04 16:29 UTC, Steve Lhomme
committed Details | Review

Description Steve Lhomme 2007-10-04 12:58:34 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:
Comment 1 Steve Lhomme 2007-10-04 13:00:51 UTC
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.
Comment 2 Tim Janik 2007-10-04 16:07:56 UTC
(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.
Comment 3 Steve Lhomme 2007-10-04 16:29:41 UTC
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.
Comment 4 Philip Withnall 2017-11-08 13:00:21 UTC
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
Comment 5 Philip Withnall 2017-11-08 13:09:12 UTC
I pushed a modified version of the patch, with a commit message I wrote (all mistakes mine).