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



_______________________________________________
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib

Reply via email to