Skip to Content.
Sympa Menu

freetds - Re: [freetds] API public header file on Windows with MS tools

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Ramiro Morales <cramm0 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] API public header file on Windows with MS tools
  • Date: Wed, 3 Aug 2011 14:33:14 -0300

On Thu, Jul 7, 2011 at 11:04 PM, James K. Lowden <jklowden AT freetds.org> wrote:
>> Index: win32/tds_sysdep_public.h
>> ===================================================================
>> RCS file: /cvsroot/freetds/freetds/win32/tds_sysdep_public.h,v
>> retrieving revision 1.8
>> diff -u -r1.8 tds_sysdep_public.h
>> --- win32/tds_sysdep_public.h   16 Mar 2009 20:46:20 -0000      1.8
>> +++ win32/tds_sysdep_public.h   7 Jul 2011 17:15:51 -0000
>> @@ -28,6 +28,7 @@
>>  {
>>  #endif
>>
>> +#define WIN32_LEAN_AND_MEAN
>
> I'd like to deliberate on this a moment.
>
> I use Nmakefile fairly often, and sought to minimize the number of
> preprocessor definitions.  I used WIN32_LEAN_AND_MEAN with Microsoft's
> versions of sqlfront.h and sqldb.h, but haven't found it necessary with
> FreeTDS.
>
> I'm using VS 2008, too.  I wonder what we're doing differently that
> causes you a problem.
>
> If it turns out to be necessary to define WIN32_LEAN_AND_MEAN, I'd
> prefer it not be in the .h file, but rather in the Nmakefile, as part
> of the DEF macro, alongside all the other goofy arbitrariness.
>

[Unfortunately the version of VS 2008 bought here is in Spanish, even
the command line tols messagesa re localized, and there is now way to
force them e.g. to English. That's why the errors below look so
strange.]

Fortunately the change that Frediano suggested in another message of
this same thread and later [1][2]committed solved the particular LPCBYTE
symbol clash with scard.h problem.

The remaining errors (a bunch of them actually) when building the
project that uses FreeTDS (pymssql) are about re-definitions of
winsock-related symbols:

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c
/nologo /Ox /MD /W3 /GS- /DNDEBUG -Iwin32\freetds\include
-Ic:\python27\include -Ic:\python27\PC /Tc_mssql.c
/Fobuild\temp.win32-2.7\Release\_mssql.obj -DMSDBLIB _mssql.c
C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\ws2def.h(91) :
warning C4005: 'AF_IPX' : redefinición de macro
C:\Program Files\\Microsoft
SDKs\Windows\v6.0A\include\winsock.h(460) : vea la definición anterior
de 'AF_IPX'
C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\ws2def.h(127) :
warning C4005: 'AF_MAX' : redefinición de macro
C:\Program Files\\Microsoft
SDKs\Windows\v6.0A\include\winsock.h(479) : vea la definición anterior
de 'AF_MAX'
C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\ws2def.h(163) :
warning C4005: 'SO_DONTLINGER' : redefinición de macro
C:\Program Files\\Microsoft
SDKs\Windows\v6.0A\include\winsock.h(402) : vea la definición anterior
de 'SO_DONTLINGER'
C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\ws2def.h(206) :
error C2011: 'sockaddr' : nueva definición del tipo 'struct'
C:\Program Files\\Microsoft
SDKs\Windows\v6.0A\include\winsock.h(485) : vea la declaración de
'sockaddr'
[...]
C:\Program Files\\Microsoft
SDKs\Windows\v6.0A\include\winsock2.h(2461) : error C2375:
WSAAsyncSelect' : nueva definición; vinculación distinta
C:\Program Files\\Microsoft
SDKs\Windows\v6.0A\include\winsock.h(934) : vea la declaracion de
'WSAAsyncSelect'
error: command '"c:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\BIN\cl.exe"' failed with exit status 2

(full build output at [3])

Again, the traditionally suggested fix for that is to exchange the order
of

#include <windows.h>
#include <winsock2.h>

so the winsock2.h one goes first.

I did so in win32/tds_sysdep_public.h and that allowed the build of
pymssql to finish succesfully.

Actually I suspect I could workaround this by adding a

#include <winsock2.h>

befor

#include "sqlfront.h"

(and a #define WIN32_LEAN_AND_MEAN too if Frediano hand't modified that)
in the relevant location (_mssql.c) of pymssql. But I'm curious about
why e.g. you with VS 2008 and people using mingw and its version of the
win32 header files haven't found the same problem. Maybe they workaround
this particular win32 common development gotcha in another way?

Regards,

--
Ramiro Morales

1.
http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/include/sqlfront.h?r1=1.6&r2=1.6.2.1&pathrev=Branch-0_91
2.
http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/include/sqlfront.h?r1=1.6.2.2&r2=1.6.2.3&pathrev=Branch-0_91
3. http://pastebin.com/uBf1tyLT




Archive powered by MHonArc 2.6.24.

Top of Page