c++ - 编译 zxing 时 Libconv 无法转换参数

标签 c++ windows visual-studio zxing iconv

我正在尝试编译 zxing library ported to C++ 在 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 .

关于c++ - 编译 zxing 时 Libconv 无法转换参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36625993/

相关文章:

c++ - static_cast 一个 void* 指针可以吗

windows - Windows 便签中的鼠标滚动

c# .net Windows 8 App TcpClient 代码端口到 StreamSocket

c# - 如何将数字转换为 ASCII 字符?

.net - 在 Visual Studio 安装程序项目中添加 .NET 6 exe 的快捷方式

c++ - 如何更改按钮的背景颜色 WinAPI C++

c++ - 我如何修改以下代码,以便我实际上将文件的内容读入一个数组然后打印出该数组?

c++ - 将仅将构造函数 move 到 vector 的对象推回

visual-studio - Visual Studio 2017 声称我正在调试我的 C++/CLI 项目的发布版本

c++ - 为什么 float 是 "unexpected type"