bug-gnulib
[Top][All Lists]
Advanced

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

Re: [bug-gnulib] Re: no rpl_mktime in mktime.c


From: Bruno Haible
Subject: Re: [bug-gnulib] Re: no rpl_mktime in mktime.c
Date: Mon, 11 Jul 2005 13:35:41 +0200
User-agent: KMail/1.5

Paul Eggert wrote:
> I thought that C++ was supposed to be namespace clean
> these days.  So isn't a standard C++ program supposed to be able to do
> this?
>
> #define mktime(x) (x)
> #include <ctime>
> int i = mktime (0);

No, this cannot work: <ctime> will typically contain a declaration like

  extern "C" {
    extern time_t ::mktime(struct tm *);
  }

which through the macro definition becomes syntactically invalid:

  extern "C" {
    extern time_t ::(struct tm *);
  }

> the usual pattern is something like this:
>
> In config.h:
>
> #define malloc rpl_malloc
>
> In malloc.c:
>
> #include <config.h>
> #undef malloc
> void *rpl_malloc (size_t n) { ... malloc (n) ... }

And when there are collision with system header files, sometimes the solution
is to move the
  #define malloc rpl_malloc
definition to gnulib's header file.

But since this is a tricky matter, we first need to have a complete analysis:
"on a redhat 
entreprise linux 3 with C++, gnulib wants to use its mktime, but in the
C++ headers mktime is undefined and then there is a build error."
- Which C++ header undefines mktime?
- Which header files are included by the program, in which order?

Bruno





reply via email to

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