[glibmm] Use std::time_t instead of ::time_t.



commit 7ee60984bb1354ef9b549450fb6e7fe1dc0d07ac
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Sep 12 16:59:08 2012 +0200

    Use std::time_t instead of ::time_t.
    
    * build/c_std.m4:
    * glib/src/date.[hg|ccg]: Use std::time_t instead of ::time_t. Only
    std::time_t is required to be declared in <ctime>, which is recommended
    instead of <time.h> in C++ programs.

 ChangeLog         |    9 +++++++++
 build/c_std.m4    |   14 +++++++-------
 glib/src/date.ccg |   10 ++++++----
 glib/src/date.hg  |   13 +++++++------
 4 files changed, 29 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 96358f3..ac9d841 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2012-09-12  Kjell Ahlstedt  <kjell ahlstedt bredband net>
 
+	Use std::time_t instead of ::time_t.
+
+	* build/c_std.m4:
+	* glib/src/date.[hg|ccg]: Use std::time_t instead of ::time_t. Only
+	std::time_t is required to be declared in <ctime>, which is recommended
+	instead of <time.h> in C++ programs.
+
+2012-09-12  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
 	Use std::size_t and std::ptrdiff_t.
 
 	* glib/glibmm/arrayhandle.h:
diff --git a/build/c_std.m4 b/build/c_std.m4
index 606aef6..f985023 100644
--- a/build/c_std.m4
+++ b/build/c_std.m4
@@ -15,23 +15,23 @@
 ## You should have received a copy of the GNU Lesser General Public License
 ## along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
-#serial 20110910
+#serial 20120912
 
 ## GLIBMM_C_STD_TIME_T_IS_NOT_INT32
 ##
-## Test whether time_t and gint32 are typedefs of the same builting type.  If
-## they aren't then they can be used for method overload.  In that case
+## Test whether std::time_t and gint32 are typedefs of the same builting type.
+## If they aren't then they can be used for method overload.  In that case
 ## GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 is defined to 1.
 ##
 AC_DEFUN([GLIBMM_C_STD_TIME_T_IS_NOT_INT32],
 [
   AC_CACHE_CHECK(
-    [whether time_t is not equivalent to gint32, meaning that it can be used for a method overload],
+    [whether std::time_t is not equivalent to gint32, meaning that it can be used for a method overload],
     [glibmm_cv_c_std_time_t_is_not_int32],
   [
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
     [[
-      #include <time.h>
+      #include <ctime>
     ]],[[
       typedef signed int gint32;
       class Test
@@ -39,7 +39,7 @@ AC_DEFUN([GLIBMM_C_STD_TIME_T_IS_NOT_INT32],
         void something(gint32 val)
         {}
 
-        void something(time_t val)
+        void something(std::time_t val)
         {}
       };
     ]])],
@@ -50,5 +50,5 @@ AC_DEFUN([GLIBMM_C_STD_TIME_T_IS_NOT_INT32],
 
   AS_VAR_IF([glibmm_cv_c_std_time_t_is_not_int32], ['yes'],
             [AC_DEFINE([GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32], [1],
-                       [Defined when time_t is not equivalent to gint32, meaning that it can be used for a method overload])])[]dnl
+                       [Defined when std::time_t is not equivalent to gint32, meaning that it can be used for a method overload])])[]dnl
 ])
diff --git a/glib/src/date.ccg b/glib/src/date.ccg
index 507c703..d8ee136 100644
--- a/glib/src/date.ccg
+++ b/glib/src/date.ccg
@@ -22,7 +22,6 @@
 //#include <glib/gmessages.h> //For g_assert() in glib < 2.15.0
 #include <glib.h> //For g_assert() in all versions of glib.
 
-#include <ctime>
 #include <algorithm>
 
 #include <glibmm/convert.h>
@@ -81,12 +80,15 @@ void Date::set_parse(const Glib::ustring& str)
 
 _DEPRECATE_IFDEF_START
 
-//Avoid a build problem in the case that time_t is equivalent to guint32 (GTime is also guint32)
+//Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32)
 //That would make the set_time() method overload impossible.
 #ifdef GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32
 void Date::set_time(GTime time)
 {
-  //This method, and the C function that it wraps, are deprecated.
+  //This method, and the C function g_date_set_time() that it wraps, are deprecated.
+  //(::time_t is used here instead of std::time_t, since the C function is declared
+  //with ::time_t. It's not important. The C++ standard requires that ::time_t
+  //and std::time_t shall be identical when both are defined.)
   g_date_set_time_t(&gobject_, static_cast<time_t>(time));
 }
 #endif //GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32
@@ -94,7 +96,7 @@ void Date::set_time(GTime time)
 _DEPRECATE_IFDEF_END
 
 
-void Date::set_time(time_t timet)
+void Date::set_time(std::time_t timet)
 {
   g_date_set_time_t(&gobject_, timet);
 }
diff --git a/glib/src/date.hg b/glib/src/date.hg
index 0bc5fc3..c6fe6dd 100644
--- a/glib/src/date.hg
+++ b/glib/src/date.hg
@@ -28,6 +28,7 @@ _DEFS(glibmm,glib)
 #include <glibmmconfig.h>
 #include <glibmm/ustring.h>
 #include <glib.h>
+#include <ctime>
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 extern "C" { struct tm; }
@@ -119,14 +120,14 @@ public:
 
   _DEPRECATE_IFDEF_START
 
-  //Avoid a build problem in the case that time_t is equivalent to guint32 (GTime is also guint32)
+  //Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32)
   //That would make the set_time() method overload impossible.
   #ifdef GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32
-  /** Sets the value of a date from a GTime (time_t) value.
+  /** Sets the value of a date from a GTime value.
    *
    * @param time GTime value to set.
    *
-   * @deprecated Please use set_time(time_t) or set_time(const GTimeVal&).
+   * @deprecated Please use set_time(std::time_t) or set_time(const GTimeVal&).
    */
   void set_time(GTime time);
   #endif //GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32
@@ -134,15 +135,15 @@ public:
   _DEPRECATE_IFDEF_END
 
 
-  /** Sets the value of a date from a <type>time_t</type> value.
+  /** Sets the value of a date from a <type>std::time_t</type> value.
    *
-   * @param timet time_t value to set
+   * @param timet std::time_t value to set
    *
    * @see set_time_current()
    *
    * Since: 2.10
    */
-  void set_time(time_t timet);
+  void set_time(std::time_t timet);
 
   /** Sets the value of a date from a GTimeVal value.  Note that the
    * tv_usec member is ignored, because Glib::Date can't make use of the



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]