Skip to Content.
Sympa Menu

freetds - Re: [freetds] LPBYTE typedef in sqlfront.h and php_mssql.c

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: jklowden AT schemamania.org
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] LPBYTE typedef in sqlfront.h and php_mssql.c
  • Date: Fri, 17 Jun 2011 18:40:54 -0400

On Fri, Jun 17, 2011 at 09:13:11PM +0000, Stuart Henderson wrote:
> On 2011-06-17, jklowden AT freetds.org <jklowden AT freetds.org> wrote:
> > On Thu, Jun 16, 2011 at 10:14:51PM +0000, Stuart Henderson wrote:
> >> http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/include/sqlfront.h?r1=1.5&r2=1.6&view=patch
> >>
> >> include/sqlfront.h r1.6 added a number of typedefs for "Better Win32
> >> compatibility", including this:
> >>
> >> +typedef BYTE * LPBYTE;
> >>
> >> It breaks build of php_mssql, would it be appropriate to #ifdef this?
> >
> > Microsoft's sqlfront.h conditions the typedef on DBNTWIN32. Would that
> > serve your purpose?
> >
> > #ifndef DBNTWIN32
> > ...
> > typedef CHAR PTR LPSTR;
> > typedef BYTE PTR LPBYTE;
> > typedef void PTR LPVOID;
> > typedef const CHAR PTR LPCSTR;
> >
> > typedef int BOOL;
> >
> > #endif
>
> Ah, they're for better compatibility with source code which was
> written for Win32 then? Sorry I misunderstood, I thought they
> were something that might be needed if compiling *on* Win32.
> (I'm building on OpenBSD).

http://msdn.microsoft.com/en-us/library/aa936949%28v=sql.80%29.aspx
http://technet.microsoft.com/en-us/library/aa936971%28v=sql.80%29.aspx
http://msdn.microsoft.com/en-us/library/aa936975%28v=sql.80%29.aspx

Microsoft's idea is that DBNTWIN32 defines the OS you're compiling for.

They don't say so, but this was really just a way
to get sqlfront.h and windows.h to place nice together.

It mostly worked.

> However if anyone's in the situation of building FreeTDS *on*
> Win32, it probably would make sense to conditionalize on DBNTWIN32.

My theory of Windows programming is never to use any proprietary headers if
you
can avoid it. The FreeTDS sqlfront.h currently compiles on my Win32/64
machines
with or without windows.h and ignores DBNTWIN32.

> In that case for my purposes it's probably best for me to just
> patch away php's typedef (it's currently in an #ifdef HAVE_FREETDS
> block; line 68 of http://tinyurl.com/3wlxuu),

I think so.

> though as far as
> getting it fixed in PHP itself goes, they should probably being
> doing a proper check and seeing whether LPBYTE is already
> available before they typedef it.

In general, yes. But for my money

unsigned char *

works just as well, and means exactly the same thing on every
machine I can imagine using.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page