bug-gnulib
[Top][All Lists]
Advanced

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

Re: gnulib and C++


From: John W. Eaton
Subject: Re: gnulib and C++
Date: Fri, 19 Feb 2010 18:40:21 -0500

On 19-Feb-2010, I wrote:

| To handle all the cases, I find that I need to write
| 
|   #ifdef __cplusplus
|   namespace gnulib
|   {
|     int (*const open) (const char *filename, int flags, ...) =
|   # if @GNULIB_OPEN@
|   #  if @REPLACE_OPEN@
|       ::rpl_open;
|   #  else
|       ::open;
|   #  endif
|   # else
|      ::open;
|   # endif
|   }
|   #endif

If I add "using gnulib::open;" inside the "#ifdef __cplusplus" block,
like this:

  #ifdef __cplusplus
  namespace gnulib
  {
    int (*const open) (const char *filename, int flags, ...) =
  # if @GNULIB_OPEN@
  #  if @REPLACE_OPEN@
      ::rpl_open;
  #  else
      ::open;
  #  endif
  # else
     ::open;
  # endif
  }
  using gnulib::open;
  #endif

then I don't even have to prefix all of the uses of open in my code
with gnulib::.  This seems like the best solution for me.  I would
prefer to avoid having to find all the places where a function is
used, and missing one could cause some confusion when the function
that is being replaced exists but doesn't work properly.  I'm not
sure, but in that case, I think the system function would be called
instead of the gnulib replacement and there would be no warning about
it.

jwe




reply via email to

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