bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sha.cpp compiler warnings


From: Elizabeth Barham
Subject: Re: sha.cpp compiler warnings
Date: 12 Dec 2002 12:59:44 -0600

Chad Yates <address@hidden> writes:

> ..\include\cc++/digest.h(384) : warning C4251: 'h' : class
> 'ost::SHATumbler<unsigned __int32>' needs to have dll-interface to be used
> by clients of class 'ost::SHA64DigestHelper'

   The thing here is that SHATumbler is not needed by clients of
SHA64DigestHelper. Originally, I was of the impression that only those
classes that needed to be used by the clients needed to be exported,
which are SHA1Digest and SHA256Digest.

> ..\include\cc++/digest.h(385) : warning C4251: 'a' : class
> 'ost::SHATumbler<unsigned __int32>' needs to have dll-interface to be used
> by clients of class 'ost::SHA64DigestHelper'

> so I gather that you can't export templated classes?  Any Ideas?
> 
> now about the warning I left out above. Following your lead, the final
> warning on ost::SHAConstant (from the first batch) can be eliminated with a
> another line added to the same WIN32 section:
> 
> > ..\include\cc++/digest.h(424) : warning C4275: non dll-interface class
> > 'ost::SHAConstant' used as base for dll-interface class
> 'ost::SHA256Digest'
> >         ..\include\cc++/digest.h(320) : see declaration of 'SHAConstant'
> 
> #ifdef WIN32
> class CCXX_CLASS_EXPORT Digest;
> class CCXX_CLASS_EXPORT ChecksumDigest;
> class CCXX_CLASS_EXPORT CRC16Digest;
> class CCXX_CLASS_EXPORT CRC32Digest;
> class CCXX_CLASS_EXPORT MD5Digest;
> class CCXX_CLASS_EXPORT SHA64DigestHelper; // new
> class CCXX_CLASS_EXPORT SHAConstant; // even newer
> class CCXX_CLASS_EXPORT SHA1Digest;
> class CCXX_CLASS_EXPORT SHA256Digest;
> #endif


   If you build the library with it the way it was originally, that
is, with the warnings and all, and only SHA1Digest and SHA256Digest
defined as CCXX_CLASS_EXPORT, does it work?

   To find out, you can write a simple program that, for instance,
provides the SHA256 hash of a file:

#include <cc++/digest.h>
#include <cstdio>

#define BUFF_SIZE 1024

int main(int argc, char * argv[])
{
        unsigned char buff[1024];
        ost::SHA256Digest d256;
        unsigned length;

        for(int i = 1 ; i < argc; i++) {
                FILE * fp = fopen(argv[i], "rb");
                d256.initDigest();

                if(fp) {
                        while(length = 
                              fread(buff, sizeof(unsigned char), BUFF_SIZE, 
fp)) {
                                d256.putDigest(buff, length);
                        }
                        
                        std::cout << d256 << "  " << argv[i] << std::endl;
                        
                        fclose(fp);
                }
        }
}

Does it work (never mind the exact result at the moment; does it
compile and run)?

Elizabeth




reply via email to

[Prev in Thread] Current Thread [Next in Thread]