我将使用DCMTK库在Visual Studio 2013下进行编程。
如果我在项目属性中设置 ,那么编译器会报错。
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
如果我设置字符集:使用多字节字符集
,我就可以解决问题。
但是我需要在另一个项目中使用DCMTK,其中字符集必须为Unicode。从错误信息来看,问题只出现在某些关于日志记录的类中,这些类可能永远不会被使用:因此,我尝试注释掉引发错误的代码行,现在我可以使用Unicode编译。
这是唯一解决问题的方法吗?如果我注释掉那部分代码会有什么问题吗?