A fix for gcc -Wconversion warning in glibmm
- From: Alexander Shaduri <ashaduri gmail com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: A fix for gcc -Wconversion warning in glibmm
- Date: Sun, 25 Apr 2010 17:20:54 +0400
Hello all,
I'm not sure if I should open a bug report for such a simple patch,
so I'm going to post it here instead (please advise on how to handle
this in the future).
Basically, this fixes the annoying gcc warning in glibmm when
-Wconversion is used:
/usr/include/glibmm-2.4/glibmm/timeval.h: In member function ‘double Glib::TimeVal::as_double() const’:
/usr/include/glibmm-2.4/glibmm/timeval.h:160:62: warning: conversion to ‘double’ from ‘long int’ may alter its value
Tested with gcc 4.5.0.
I'm attaching a patch (against glibmm master) which fixes the
warning by making an explicit cast where an implicit one was
being made.
Thanks,
Alexander
diff --git a/glib/glibmm/timeval.h b/glib/glibmm/timeval.h
index 685f783..03202a1 100644
--- a/glib/glibmm/timeval.h
+++ b/glib/glibmm/timeval.h
@@ -157,7 +157,7 @@ TimeVal& TimeVal::operator-=(long seconds)
inline
double TimeVal::as_double() const
{
- return tv_sec + ((double) tv_usec / (double) G_USEC_PER_SEC);
+ return (double)tv_sec + ((double) tv_usec / (double) G_USEC_PER_SEC);
}
inline
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]