delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/09/02/02:08:30

From: Graham DOT Dumpleton AT nms DOT otc DOT com DOT au (Graham Dumpleton)
Subject: sys/socket #define problem
2 Sep 1997 02:08:30 -0700 :
Sender: mail AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199709010020.KAA13835.cygnus.gnu-win32@baldric.pad.otc.com.au>
Original-To: gnu-win32 AT cygnus DOT com
X-Mailer: ELM [version 2.4 PL24]
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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 (grahamd AT nms DOT otc DOT com DOT au)
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019