bug-commoncpp
[Top][All Lists]
Advanced

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

Compile Error with Visual C++ .NET (7.0)


From: Tobias Erbsland
Subject: Compile Error with Visual C++ .NET (7.0)
Date: Fri, 19 Dec 2003 15:04:25 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4


I got some compile errors with Visual C++ .NET (7.0):
(latest CVS checkout)

urlstring.cpp
d:\commoncpp2\src\urlstring.cpp(266) : error C2057: expected constant
expression
d:\commoncpp2\src\urlstring.cpp(266) : error C2466: cannot allocate an
array of constant size 0
d:\commoncpp2\src\urlstring.cpp(266) : error C2133: 'buffer' : unknown size
d:\commoncpp2\src\urlstring.cpp(284) : error C2057: expected constant
expression
d:\commoncpp2\src\urlstring.cpp(284) : error C2466: cannot allocate an
array of constant size 0
d:\commoncpp2\src\urlstring.cpp(284) : error C2133: 'buffer' : unknown size
d:\commoncpp2\src\urlstring.cpp(301) : error C2057: expected constant
expression
d:\commoncpp2\src\urlstring.cpp(301) : error C2466: cannot allocate an
array of constant size 0
d:\commoncpp2\src\urlstring.cpp(301) : error C2133: 'buffer' : unknown size

All functions in this kind:

CCXX_EXPORT(String) b64Encode(const String& src)
{
  size_t limit = (src.length()+2)/3*4+1;  // size + null must be included
  char buffer[limit];

  unsigned size = b64Encode((const unsigned char *)src.c_str(),
src.length(), buffer, limit);
  buffer[size] = '\0';

  return String(buffer);
}

must replaced by:

CCXX_EXPORT(String) b64Encode(const String& src)
{
  size_t limit = (src.length()+2)/3*4+1;  // size + null must be included
  char* buffer = new char[limit];

  unsigned size = b64Encode((const unsigned char *)src.c_str(),
src.length(), buffer, limit);
  buffer[size] = '\0';

  String str(buffer);
  delete[] buffer;

  return str;
}

regards
Tobias

Attachment: pgplwxAXbhDrF.pgp
Description: PGP signature


reply via email to

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