c++ - DCMTK 字符集 Unicode 错误

标签 c++ unicode visual-studio-2013 dicom dcmtk

我在 Visual Studio 2013 下使用 DCMTK 库。 在项目的属性中,如果我设置

Character Set: Use Unicode Character Set

编译时出现错误

Error   1   error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const wchar_t [8]' (or there is no acceptable conversion)   C:\DCMTK\include\dcmtk\oflog\tracelog.h
Error   2   error C2664: 'void dcmtk::log4cplus::Logger::forcedLog(const dcmtk::log4cplus::spi::InternalLoggingEvent &) const' : cannot convert argument 3 from 'int' to 'const char *'   C:\DCMTK\include\dcmtk\oflog\tracelog.h 
Error   3   error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const wchar_t [8]' (or there is no acceptable conversion)   C:\DCMTK\include\dcmtk\oflog\tracelog.h
Error   4   error C2664: 'void dcmtk::log4cplus::Logger::forcedLog(const dcmtk::log4cplus::spi::InternalLoggingEvent &) const' : cannot convert argument 3 from 'int' to 'const char *'   C:\DCMTK\include\dcmtk\oflog\tracelog.h
Error   5   error C2665: 'dcmtk::log4cplus::Logger::getInstance' : none of the 2 overloads could convert all the argument types   C:\DCMTK\include\dcmtk\oflog\logmacro.h
IntelliSense: no instance of overloaded function "dcmtk::log4cplus::Logger::getInstance" matches the argument list
            argument types are: (const dcmtk::log4cplus::tchar *)   c:\DCMTK\include\dcmtk\oflog\logmacro.h
IntelliSense: no operator "+" matches these operands
            operand types are: const wchar_t [8] + dcmtk::log4cplus::tstring   c:\DCMTK\include\dcmtk\oflog\tracelog.h
IntelliSense: no operator "+" matches these operands
            operand types are: const wchar_t [8] + dcmtk::log4cplus::tstring   c:\DCMTK\include\dcmtk\oflog\tracelog.h
IntelliSense: identifier "cerr" is undefined   c:\Users\Kyle\Google Drive\cpp_codes\dicom\DicomTest\test1\Source.cpp
IntelliSense: identifier "endl" is undefined   c:\Users\Kyle\Google Drive\cpp_codes\dicom\DicomTest\test1\Source.cpp

如果我设置 Character Set: Use Multi-Byte Character Set 就可以解决

但我需要在另一个字符集必须是 Unicode 的项目中使用 DCMTK。查看错误,问题仅出在我可能永远不会使用的有关日志记录的某些类中:因此我尝试注释出现错误的代码行,现在我可以使用 Unicode 进行编译。

这是解决问题的唯一方法?评论那部分有什么问题?

最佳答案

根据DCMTK的INSTALL文件:

“当定义了 UNICODE 或 _UNICODE 时,DCMTK 不会编译,因为 然后 VisualStudio 编译器使用 Unicode 版本而不是 ANSI 所有 Windows API 函数的版本(即键入 wchar_t 而不是 char 对于所有字符串参数和返回值)。”

也许,您应该使用具有动态链接的 DCMTK(作为 DLL)。但是,这需要使用当前的开发快照而不是最新版本(3.6.0)。

关于c++ - DCMTK 字符集 Unicode 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28106665/

相关文章:

c++ - 使用 for_each 函数显示每个容器元素

c++ - 如果我将 char 输入提供给 C++ 中的 int 数据类型,会发生什么情况?

c++ - 将指针声明为类成员 C++

c++ - 如何通过 WH_KEYBOARD_LL Hook 程序发送输入消息

c++ - 为什么我在 Visual Studio 中收到堆栈溢出错误

c++ - 无法将参数 1 从 int 转换为 int && 错误

python - 为什么 python-cgi 在 unicode 上失败?

php - 正确从 MySQL 中提取 Unicode 字符 [PHP MYSQL]

c++ - 如何将重音字母 (wchar_t) 转换为 char?

regex - 在 Visual Studio 2013 中查找换行符