On Tue, 2003-03-11 at 23:33, Guido Serassio wrote:
> Hi Robert,
> 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)Yes, if there are other conflicts. > }; > > >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 ? It needs to be a namespace that we can use throughout squid, yet is private to squid as far as OS includes goes : thus Squid is a good name for it. this is what we will end up with : ::connect(a,b,c) ::Squid::connect(a,b,c) ::ConnectState::connect() and you can see that there are no conflicts. As long as the code that uses connect(a,b,c) is scoped correctly (thus the using namespace Squid; in squid.h) we will call the correct connect all the time. Rob -- GPG key available at: <http://users.bigpond.net.au/robertc/keys.txt>.
signature.asc
Description: This is a digitally signed message part
