Subject: sys/socket #define problem
From: [email-masked] (Graham Dumpleton)

2 Sep 1997 02:08:30 -0700
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked]
X-Mailer: ELM [version 2.4 PL24]
Content-Type: text
Original-Sender: [email-masked]

This seemed to get caught up in the recent mail black hole. Apologies if it
turns up twice.

In sys/socket.h, there exists a whole bunch of #define's like:

#define bind cygwin32_bind
....

The intent is to ensure that the Win32 versions of these functions are not
used. Can some other way be found of doing this, or for C++ at least, can
they be made into C++ inline functions.

The problem is that some of the names are common enough that one might use
them as member function names in C++ classes. To an extent this isn't a
problem, however, it is if the order of #include's is such that you include
sys/socket.h after the header file which used one of these names, eg. bind.
After the point where sys/socket.h is included, your use of the name gets
changed, with the cygwin32_ prefix being added. A number of things can
happen. If your version of the function had the same prototype, but, was a
member of a class, the compiler will quite silently compile the file as
okay, however, in reality, it has called the wrong function, not calling
your function in the class, but the system bind. A second possibility is
that your function had a different prototype in which case it will not find
the function and the compiler will given an error. A similar case would be
where the name was used as a member variable name, the compiler simply
wouldn't find it.

-- 
Graham Dumpleton ([email-masked])
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".