bug-gnulib
[Top][All Lists]
Advanced

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

#define FOO rpl_FOO in config.h


From: John W. Eaton
Subject: #define FOO rpl_FOO in config.h
Date: Tue, 29 Nov 2011 03:01:07 -0500

While trying to cross compile Octave for MinGW, I hit the following
errors:

  In file included from /home/jwe/src/octave/liboctave/oct-time.h:26:0,
                   from /home/jwe/src/octave/liboctave/file-stat.h:28,
                   from /home/jwe/src/octave/liboctave/file-ops.cc:43:
  /usr/include/c++/4.6/ctime:72:11: error: '::gmtime' has not been declared
  /usr/include/c++/4.6/ctime:73:11: error: '::localtime' has not been declared

The problem seems to be that config.h includes the lines 

  /* Define to rpl_gmtime if the replacement function should be used. */
  #define gmtime rpl_gmtime

  /* Define to rpl_localtime if the replacement function should be used. */
  #define localtime rpl_localtime

and the ctime header has

  #include <time.h>

  ...

  // Get rid of those macros defined in <time.h> in lieu of real functions.
  #undef clock
  #undef difftime
  #undef mktime
  #undef time
  #undef asctime
  #undef ctime
  #undef gmtime
  #undef localtime
  #undef strftime

  namespace std
  {
    using ::clock_t;
    using ::time_t;
    using ::tm;

    using ::clock;
    using ::difftime;
    using ::mktime;
    using ::time;
    using ::asctime;
    using ::ctime;
    using ::gmtime;
    using ::localtime;
    using ::strftime;
  } // namespace

Also, defining gmtime and localtime in config.h could cause trouble
for classes that have member functions with those names.

Surrounding the definitions in the config.h file with #ifndef
__cplusplus/#endif allowed me to get past the error, but that doesn't
seem like the right fix.

Would it be possible to handle these definitions in gnulib's time.h
instead of inserting them in config.h?

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]