bug-commoncpp
[Top][All Lists]
Advanced

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

Re: Compilation under win32 broken


From: Elizabeth Barham
Subject: Re: Compilation under win32 broken
Date: 25 Apr 2003 13:35:21 -0500

"W.J." <address@hidden> writes:

> When compiling CommonC++ 1.0.9 under win32 (MSDev 6) I get the
> following error:
> 
> src\sha.cpp(338): error C2593: 'operator <<' is ambigious

template <class int_type>
std::ostream & SHATumbler<int_type>::toString(std::ostream & os)
{
        unsigned i;
        int_type h1, h2;

        for(i = 0 ; i < (unsigned)size ; i++) {
                h1 = h[i] / ( 1 << sizeof(int_type) * 4);
                h2 = h[i] % ( 1 << sizeof(int_type) * 4);
                os << std::hex << std::setw(sizeof(int_type) / 4) << 
                        std::setfill('0') << h1 << h2; // <---- here
        }
        return(os);
}

> I 'fixed' this by putting (int) in front of h1 and h2, but I have no
> idea if this does the right thing..

   To be honest with you, I do not know who added h1 and h2 or
why. There was a discussion about this but whoever added h1 and h2 did
not explain his or her self.

   Originally, it looked like this:

template <class int_type>
std::ostream & SHATumbler<int_type>::toString(std::ostream & os)
{
        for(int i = 0 ; i < size ; i++) {
                os << std::hex << std::setw(sizeof(h[i]) * 2) << 
                        std::setfill('0') << h[i];
        }
        return(os);
}

   Further, whoever added h1 and h2 messed it up so that the correct
digest wasn't even displayed! I added the:

        h1 = h[i] / ( 1 << sizeof(int_type) * 4);

business which corrected the others errors as I was assuming that
whoever added h1 and h2 did it for very good reasons but was not
monitoring the mailing list or did not want to speak up.

   Ideally, h1 and h2 would be given a type that has a size of
int_type / 2.

   If you modify it back to the way it was, the implementation that
does not use h1 and h2, are there any errors?

   Another idea is to split the "os <<" line into two lines:

                os << std::hex << std::setw(sizeof(int_type) / 4) << 
                        std::setfill('0') << h1;
                os << std::hex << std::setw(sizeof(int_type) / 4) << 
                        std::setfill('0') << h2;

> Furthermore, on linking it gives a error about being unable to find
> '_thiscall ost::SHATumbler<unsigned __int32>::placeInBuffer(unsigned
> char*)'
> (occurences in digest.obj and md5.obj)

Perhaps because placeInBuffer is not called in sha.cpp the compiler
assumes it is not needed. There should be some kind of work around,
such as adding:

unsigned SHATumbler<unsigned __int32>::placeInBuffer(unsigned char *);

at the end of sha.cpp (or some other kludge).

#ifdef __WIN32__ // whatever it is
unsigned SHATumbler<unsigned __int32>::placeInBuffer(unsigned char *);
#endif

Thanks for letting us know about this.

Elizabeth




reply via email to

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