Compilation error using zlib.bi

Windows specific questions.
tontin1970
Posts: 6
Joined: Apr 23, 2006 19:31

Compilation error using zlib.bi

Postby tontin1970 » May 26, 2006 0:32

Hi all,

Hope you can help with this. I could not find the solution.

When I compile the program it returns the error :

Line 18 c:\freebasic\inc\zlib.bi Duplicate definition type uInt as uinteger

if i commnet out that line in zlib.bi i get this error:

Line 18 c:\freebasic\inc\zlib.bi Duplicate definition type uLong as uinteger

and if I commnet out that line I get this error:

Line 39 error 57 c:\freebasic\inc\zlib.bi Illigal specification, at parameter 2:
type alloc_func as function cdecl (byval as voidpf, byval as uInt, byval ...

Searching the freebasic\inc folder down I found that zlib.bi and win\windef.bi have the same definitions type uInt as uinteger and
type uLong as uinteger is also defined in winnt.bi
therefore the first two errors are because of that. I got it.

But if I comment out this definitions in either of those three files then I will get errors for not defining that variable.

Basicly the code is like this:





Code: Select all

   
 OPTION EXPLICIT

#INCLUDE ONCE "WINDOWS.BI"
#INCLUDE ONCE "DialogFunctions.bi" 
#INCLUDE ONCE "vbcompat.bi"
#INCLUDE ONCE "zlib.bi"


declare function compact(archivo_in as string, archivo_out as string)as integer
declare function expand(archivo_in as string, archivo_out as string)as integer

'Here all the code for the dialog window and all the subs and functions

function compact(archivo_in as string, archivo_out as string) as integer
end function

function expand (archivo_in as string, archivo_out as string) as integer
end function


I hav been programming in VB but I am just starting in FB. Any help will be very wellcome.

I did not show the whole code because is a bit long and the program was working perfect until I added the zlib.bi. And also the functions: compact and expand are copies of a progam posted here, that works ok as a stand alone programs.


TIA

Tontin1970
v1ctor
Site Admin
Posts: 3799
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Postby v1ctor » May 26, 2006 0:42

Try the latest headers with 0.16, see the News forum on this board.

Btw, the Win API defines quite ordinary names like OPAQUE, as FB is case-insensitive, that will clash with a zlib "opaque as voidpf" field in the z_stream_s type, change the field to "opaque_ as voidpf" - constants are declared with #define's to speed up parsing the headers (they are much faster than CONST because nothing is evaluated until referenced), so they can replace anything.

Fix commited to CVS.
voodooattack
Posts: 605
Joined: Feb 18, 2006 13:30
Location: Alexandria / Egypt
Contact:

Postby voodooattack » May 26, 2006 0:46

try this:

Code: Select all

#INCLUDE ONCE "zlib.bi"
#undef uInt
#undef uLong
#undef Bytef
#undef charf
#undef intf
#undef uIntf
#undef uLongf
#undef voidpc
#undef voidpf
#undef voidp
#INCLUDE ONCE "WINDOWS.BI"
#INCLUDE ONCE "DialogFunctions.bi"
#INCLUDE ONCE "vbcompat.bi"
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » May 26, 2006 1:06

For a small app where I needed only minimal functionality I just replaced zlib.bi with this:

Code: Select all

#inclib "z"

declare function compress2 cdecl alias "compress2" ( _
    byval dest as Byte ptr, _
    byval destLen as uLong ptr, _
    byval source as Byte ptr, _
    byval sourceLen as uLong, _
    byval level as integer) _
    as integer

declare function uncompress cdecl alias "uncompress" ( _
    byval dest as Byte ptr, _
    byval destLen as uLong ptr, _
    byval source as Byte ptr, _
    byval sourceLen as uLong) _
    as integer
   
#define Z_DEFAULT_COMPRESSION (-1)
#define Z_OK 0
#define Z_STREAM_ERROR (-2)
#define Z_DATA_ERROR (-3)
#define Z_MEM_ERROR (-4)
#define Z_BUF_ERROR (-5)
tontin1970
Posts: 6
Joined: Apr 23, 2006 19:31

Compilation error using zlib.bi

Postby tontin1970 » May 26, 2006 15:51

Thank you.

I tested options given by voodooattack an MichaelW and they work fine.

V1ctor's haven't done yet.

Regards,

Tontin1970

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 6 guests