Ted wrote:
I just noticed that zlib is part of Indy so I decided to drop the very
old zlib download I've used so far and try using the one in Indy.
Delphi/C++Builder has had its own copy of ZLib for awhile now, in the System.ZLib
unit, which Indy has not been updated to use yet. I would not suggest using
Indy's ZLib standalone, it is primarily meant for zlib compression in TIdHTTP
specifically (and in the future, TIdHTTPServer).
I see. I'm mainly maintaining an old BCB4 project in which I've used a ZLib I downloaded in 2005. I've also used RS2007 to create a C++ DLL containing all the Indy stuff needed to keep the old BCB4 project alive (TLS 1.2 support etc) and was now thinking of adding support to use Indys Zlib to that DLL - to get any updates of ZLib that might be brought into Indy for free so to say.
I found the ZLib included in RS2007 now. It says zlib_Version 1.0.4 and the version I currently use is 1.2.3 - so if using Indy's TIdCompressorZLib isn't recommended, I'm probably better off keeping my own ZLib copy up-to-date and to make some wrapper classes for it to avoid regression.
It seems to be complaining about these:
#if alignof(z_stream) < 1
alignof() was added to C++Builder in CB2009 (in addition to other C++0x features
before C++11 was finalized):
[...]
Here is a page that shows how to implement alignof() manually:
http://www.wambold.com/Martin/writings/alignof.html
If that works, I can look into incorporating it into IdZLibHeaders.hpp.
Oh, that'd be great. I downloaded that alignof implementation and perhaps it's possible to make something that works in a conditional compiler directive out of it.
I added my own definition of alignof and test thereof in my form's header file like this:
#define alignof(x) 0
#include "IdCompressorZLib.hpp"
#include "IdZLibCompressorBase.hpp"
#include <IdBaseComponent.hpp>
#if alignof(z_stream) < 1
#pragma message ("Hello world")
#endif
The compilation was then ok and I got the "Hello world" message, but I didn't get the warning message from within IdZLibHeaders.hpp I was expecting.
Compressing a file with this program and then uncompressing it with gunzip worked fine.
Indy is written in Delphi, not C++, and the IDE does not use .hpp files generated
for Delphi components.
Ah...
... what to do about it. I'd prefer if I didn't have to modify the
Indy headers since that will make this problem reappear when
I upgrade Indy next time.
Unless the changes are incorporated into IdZLibHeaders.pas itself, which
has {$HPPEMIT} statements used when generating IdZLibHeaders.hpp, including
the alignof() statements.
That sounds nice. I'll try to do something out of the alignof implementation you sent - or what about this?
(*$HPPEMIT '#if __BORLANDC__ > 0x0593'*)
(*$HPPEMIT '#if alignof(z_stream) > 1'*)
...
I guess the directives to print out the "Pascal/C++ alignment mismatch" and "Pascal/C++ size mismatch" warnings were added for a reason but I wonder if isn't possible to make sure that the Pascal/C++ alignments and sizes always match (where it really matters) to get rid of the reason for these checks altogether? If these checks are important it seems a little risky to just send a warning via a pragma message that by default isn't shown in the (RS2007) IDE.
Br,
Ted
Connect with Us