编译 zxing 时 Libconv 无法转换参数

Libconv cannot convert argument when compiling zxing

我正在尝试编译移植到 C++ 的 zxing 库 Windows 7 (64) 使用 Visual Studio 2015.

我按照自述文件中描述的步骤使用 Cmake 生成 .sln 和 .vcxproj 文件。

但是,当我构建代码时出现此错误:

Severity Code Description Project File Line Suppression State Error C2664 'size_t libiconv(libiconv_t,const char **,size_t *,char **,size_t *)': cannot convert argument 2 from 'char **' to 'const char **'

行:

    iconv(ic, &ss, &sl, &ds, &dl);

这是发生错误的部分代码:

#include <zxing/aztec/decoder/Decoder.h>
#ifndef NO_ICONV 
#include <iconv.h>
#endif
#include <iostream>
#include <zxing/FormatException.h>
#include <zxing/common/reedsolomon/ReedSolomonDecoder.h>
#include <zxing/common/reedsolomon/ReedSolomonException.h>
#include <zxing/common/reedsolomon/GenericGF.h>
#include <zxing/common/IllegalArgumentException.h>
#include <zxing/common/DecoderResult.h>
using zxing::aztec::Decoder;
using zxing::DecoderResult;
using zxing::String;
using zxing::BitArray;
using zxing::BitMatrix;
using zxing::Ref;

using std::string;


namespace {
 void add(string& result, char character) {
#ifndef NO_ICONV
  char character2 = character & 0xff;
  char s[] =  {character2};
  char* ss = s;
  size_t sl = sizeof(s);
  char d[4];
  char* ds = d;
  size_t dl = sizeof(d);
  iconv_t ic = iconv_open("UTF-8", "ISO-8859-1");
  iconv(ic, &ss, &sl, &ds, &dl); //<<<< at this line
  iconv_close(ic);
  d[sizeof(d)-dl] = 0;
  result.append(d);
#else
  result.push_back(character);
#endif
}
...

感谢您的帮助!

这是iconv的签名:

size_t iconv (iconv_t cd,
              const char* * inbuf, size_t * inbytesleft,
              char* * outbuf, size_t * outbytesleft);

但是您调用 iconv 时使用 char* 作为第二个参数而不是 const char**

Here is a complete example.