Annie
Annie

Reputation: 3190

Zlib in Visual Studio 2012

I am following these instructions to test the zlibStat library with testzlib. When I try to build testzlib, it throws the following error in testzlib.c, Line: 167, Char:43:

IntelliSense: argument of type "unsigned char **" is incompatible with parameter of type "void **"

Is it a specification change in C11, a bug in VC 11 or a bad code?

Is there a workaround? I tried changing unsigned char* FilePtr; to void* FilePtr;, but then the assignment operator throws the error on Line 200. Any thoughts?


Solution

I followed Icepack's answer. Then I got an error on line 141, so I changed it to *pFilePtr=(unsigned char*)ptr;. Hopefully zlib guys would update their code accordingly.

Upvotes: 2

Views: 1287

Answers (1)

SomeWittyUsername
SomeWittyUsername

Reputation: 18338

Implicit conversion doesn't work with double indirection. Converting char* to void* is ok, but char** to void** isn't. See here for more details: http://c-faq.com/ptrs/genericpp.html

Try replacing the ReadFileMemory signature with ReadFileMemory(const char* filename,long* plFileSize,unsigned char** pFilePtr).

Upvotes: 3

Related Questions