Re: Another new build problem on nt branch

From: Guido Serassio <serassio@dont-contact.us>
Date: Tue, 11 Mar 2003 13:33:51 +0100

Hi Robert,

At 13.12 11/03/2003, Robert Collins wrote:

>On Tue, 2003-03-11 at 22:42, Guido Serassio wrote:
> > Hi,
> >
> > I have found a new build problem trying to build the nt branch:
> >
> > comm.cc:57:18: macro "connect" requires 3 arguments, but only 1 given
> > comm.cc:57: variable or field `connect' declared void
>...
> > #define connect(s,n,l) squid_connect(s,n,l)
>
>Yep, defines are generally evil and prone to breakage.
>
>I take it that you need to replace calls to ::connect(a,b,c) in the
>squid code with a call to :: squid_connect (a,b,c) ?

Correct.

>Well, one answer is:
>namespace Squid {
>inline int connect (s,n,l) {return squid_connect(s,n,l);}
>};
>(pesudoish code).

So, for example, in squid-mswin.h connect will be:

namespace Squid {

inline
int connect(int s, const struct sockaddr * n, int l)
{
     if (::connect(_get_osfhandle(s),n,l) == SOCKET_ERROR) {
         if (WSAEMFILE == (errno = WSAGetLastError()))
             errno = EMFILE;
         return -1;
     }
     else
         return 0;
}

(I think that other similar functions comes here too)

};

>Then, in squid.h, add :
>'using namespace Squid;
>
>What this does is makes unguarded calls to a global connect(a,b,c) use
>that inline function. Calls that need the original connect can use
>::connect(a,b,c).

OK, but there is some risk of future namespace conflicts, aka a "Squid"
namespace will be safe ? or it will be better something like a Squid_MSWIN
namespace ?

Regards

Guido

-
=======================================================
Serassio Guido
Via Albenga, 11/4 10134 - Torino - ITALY
E-mail: guido.serassio@serassio.it
WWW: http://www.serassio.it
Received on Tue Mar 11 2003 - 05:34:27 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:19:32 MST