[Top][All Lists]

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

Re: predefined CPP macros

From: Bruno Haible
Subject: Re: predefined CPP macros
Date: Sat, 11 Oct 2008 02:18:58 +0200
User-agent: KMail/1.5.4

Hi Simon,

> >                       |  native fd    |   gnulib      | native SOCKET |
> >                       |               |  wrapped fd   |               |
> > -----------------------------------------------------------------------
> > ReadFile, WriteFile   |               |               |      YES      |
> > -----------------------------------------------------------------------
> > MSVCRT recv, send     |               |               |      YES      |
> > -----------------------------------------------------------------------
> > MSVCRT read, write    |     YES       |     YES       |               |
> > -----------------------------------------------------------------------
> Thanks.  Is there a place in the gnulib manual to add this?

The contents of this matrix can be summarized in two sentences:
  - 'int fd' and SOCKET are different data types.
  - SOCKETs are HANDLEs and can be used with ReadFile and WriteFile.
  - 'int fd' can be used with POSIX functions like read() and write().
But feel free to augment the doc.

> I searched for your _WIN32/CYGWIN/etc CPP macro matrix yesterday, and
> having that in the gnulib manual as well would have saved me time.

The reference for this ought to be http://predef.sourceforge.net/, but if
you want to write something about it in the gnulib doc, then:

  - The test whether native Win32 API is available is
      (defined _WIN32 || defined __WIN32__).
    Which of the two symbols is defined, depends on the compiler.

  - Cygwin is a POSIX implementation on which the Win32 API is _optionally_
    available. On Cygwin, this expression may evaluate to true or false,
    depending whether the developer wants to compile his programs in such
    a way that they can access Win32 API or not.

  - For POSIX functionality that is already implemented in Cygwin, there is
    no need to use the Win32 API, therefore here we use the conditional
      (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__.

  - For access to Win32 functionality that has no overlap with POSIX, the
    right conditional is
      (defined _WIN32 || defined __WIN32__).


reply via email to

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