hello Everyone,

I have a problem with type casting. My code is

zcpr.next_in = FilePtr;

next_in is a element of the zcpr structure where its type is and FilePtr is a void type pointer. zcpr is a z_stream type structure and next_in is a Bytef type pointer.

This code is a part of zlib library. Let me khow how to solve this type casting.

zlib I think was written in C language, not C++. If you want to compile it as c++ then there will most likely be a lot of places that require minor changes, such as typcasting void* to something else, such as zcpr.next_in = (Bytef *)FilePtr;

The zlib library is written in C. But I want to use in a C++ application. Is it a good idea to compile it under C++ environment in VC++?

If I try to compile it under C++, it gives a lot of error.

inftrees.c(48) : error C2143: syntax error : missing ';' before 'this'
.\inftrees.c(48) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(113) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(113) : error C2228: left of '.op' must have class/struct/union
.\inftrees.c(114) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(114) : error C2228: left of '.bits' must have class/struct/union
.\inftrees.c(115) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(115) : error C2228: left of '.val' must have class/struct/union
.\inftrees.c(116) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(117) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(213) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(213) : error C2228: left of '.bits' must have class/struct/union
.\inftrees.c(215) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(215) : error C2228: left of '.op' must have class/struct/union
.\inftrees.c(216) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(216) : error C2228: left of '.val' must have class/struct/union
.\inftrees.c(219) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(219) : error C2228: left of '.op' must have class/struct/union
.\inftrees.c(220) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(220) : error C2228: left of '.val' must have class/struct/union
.\inftrees.c(223) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(223) : error C2228: left of '.op' must have class/struct/union
.\inftrees.c(224) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(224) : error C2228: left of '.val' must have class/struct/union
.\inftrees.c(233) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(293) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(293) : error C2228: left of '.op' must have class/struct/union
.\inftrees.c(294) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(294) : error C2228: left of '.bits' must have class/struct/union
.\inftrees.c(295) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(295) : error C2228: left of '.val' must have class/struct/union
.\inftrees.c(302) : error C2673: 'inflate_table' : global functions do not have 'this' pointers
.\inftrees.c(302) : error C2228: left of '.bits' must have class/struct/union
.\inftrees.c(306) : error C2673: 'inflate_table' : global functions do not have 'this' pointers

How to deal with these errors? Obviously C++ will not let use this pointer without a class.

Edited 6 Years Ago by Nick Evan: Replaced tags

Comments
Incredibly poor choice of an alternative to [code][/code] tags.
This article has been dead for over six months. Start a new discussion instead.