Crypto Library builds fine, but while I use it in my project there is compile error

39 views
Skip to first unread message

manasi deshpande

unread,
Mar 31, 2016, 12:03:06 AM3/31/16
to Crypto++ Users
I have used 
#include "md5.h"
#include "hex.h"

and I get the compile error in "algparam.h"

template <class T>
class AlgorithmParametersTemplate : public AlgorithmParametersBase
{
public:
AlgorithmParametersTemplate(const char *name, const T &value, bool throwIfNotUsed)
: AlgorithmParametersBase(name, throwIfNotUsed), m_value(value)
{
}

void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const
{
// special case for retrieving an Integer parameter when an int was passed in
if (!(g_pAssignIntToInteger != NULL && typeid(T) == typeid(int) && g_pAssignIntToInteger(valueType, pValue, &m_value)))
{
NameValuePairs::ThrowIfTypeMismatch(name, typeid(T), valueType);
*reinterpret_cast<T *>(pValue) = m_value;
}
}

void MoveInto(void *buffer) const
{
AlgorithmParametersTemplate<T>* p = new(buffer) AlgorithmParametersTemplate<T>(*this);
CRYPTOPP_UNUSED(p); // silence warning
}

protected:
T m_value;
};

Error 3 error C2061: syntax error : identifier 'buffer' c:\md5\cryptopp563\algparam.h

manasi deshpande

unread,
Mar 31, 2016, 12:17:41 AM3/31/16
to Crypto++ Users
I am on VS2013 and built the crypto++ library on vs10

Jeffrey Walton

unread,
Mar 31, 2016, 12:35:59 AM3/31/16
to Crypto++ Users

Something looks fishy... 'buffer' is clearly present in MoveInto. I'm also wondering about the "Error3" and why the compiler did not emit the line number.

Can you duplicate it with the latest sources? You can get the sources from https://github.com/weidai11/cryptopp by clicking the "Download ZIP" button.

Jeff

manasi deshpande

unread,
Mar 31, 2016, 1:29:18 AM3/31/16
to Crypto++ Users
Hi Jeffrey,

I updated it with latest sources. It doesn't make any difference!. 

It still gives the compile error for buffer! I am unable to resolve the same! :(

Manasi

Jeffrey Walton

unread,
Mar 31, 2016, 12:08:51 PM3/31/16
to Crypto++ Users


On Thursday, March 31, 2016 at 1:29:18 AM UTC-4, manasi deshpande wrote:
Hi Jeffrey,

I updated it with latest sources. It doesn't make any difference!. 

It still gives the compile error for buffer! I am unable to resolve the same! :(

I tested the GitHub ZIP against Windows 8 Pro and Visual Studio 2013 Pro. I cannot duplicate the issue.

I think you will need to explain more about your setup and what you are doing. For example, Where is the Crypto++ library installed, and how did you set your project up?

Jeff

trungantran

unread,
Mar 31, 2016, 12:25:35 PM3/31/16
to Crypto++ Users
You may have a "buffer" macro defined some where. To check this, search all solution for the "buffer" keyword. 

Jeffrey Walton

unread,
Mar 31, 2016, 3:37:53 PM3/31/16
to Crypto++ Users

Error 3 error C2061: syntax error : identifier 'buffer' c:\md5\cryptopp563\algparam.h


You may have a "buffer" macro defined some where. To check this, search all solution for the "buffer" keyword. 

That's a good point.

The library uses a few macros with 'buffer' in them, but none of them look like the culprit. The ones in the .S file are for GCC, so they can be ignored.

$ grep -IR 'buffer' * | grep define
lubyrack.h:#define BL this->buffer
lubyrack.h:#define BR this->buffer+this->S
rdrand.S:       %define buffer edi
rdrand.S:%define buffer  rdi
rdrand.S:       %define buffer edi
rdrand.S:%define buffer  rdi

Jeff

manasi deshpande

unread,
Apr 1, 2016, 6:44:32 AM4/1/16
to Crypto++ Users
Hello,

If I have a macro named as "buffer", then changing the name in header file should resolve the issue! I checked in my solution, don't find any Macro with name "buffer".

I am on windows 7 and VS2013. 

Jeffrey Walton

unread,
Apr 1, 2016, 1:49:50 PM4/1/16
to Crypto++ Users


If I have a macro named as "buffer", then changing the name in header file should resolve the issue!...

Clean you precompiled headers, too. Build → Batch Build → Clean All.

Jeff

Jeffrey Walton

unread,
Apr 1, 2016, 1:56:21 PM4/1/16
to Crypto++ Users

Also ensure you are compiling the sources as C++ with the /Tp option. http://msdn.microsoft.com/en-us/library/032xwy55.aspx

Jeff

Geoff Beier

unread,
Apr 1, 2016, 4:14:39 PM4/1/16
to manasi deshpande, Crypto++ Users
On Thu, Mar 31, 2016 at 12:17 AM, manasi deshpande <manu...@gmail.com> wrote:
I am on VS2013 and built the crypto++ library on vs10


Are you saying that you are attempting to use a library you built with Visual Studio 2010 in an application you built with Visual Studio 2013?

I cannot point to documentation for this, but I would not expect this to work.

It is probably not the cause of your compilation error, but if you attempt to use a C++ library with a C++ interface built with 2010 tools inside an application built with 2013 tools, I would expect you'll see non-deterministic, hard-to-diagnose crashes.

Is there a reason you built the library with 2010 and your program with 2013?

Geoff

Reply all
Reply to author
Forward
0 new messages