gpt4 book ai didi

c++ - DCMTK 字符集 Unicode 错误

转载 作者:太空狗 更新时间:2023-10-29 21:41:46 24 4
gpt4 key购买 nike

我在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com