错误处理--pure specifier can only be specified for functions
错误处理--pure specifier can only be specified for functions
今天下载了log4cpp的源代码,在VC6下编译时出现错误:
..\..\include\log4cpp/Priority.hh(65) : error C2258: illegal pure syntax, must be '= 0'
..\..\include\log4cpp/Priority.hh(65) : error C2252: 'MESSAGE_SIZE' : pure specifier can only be specified for functions
..\..\include\log4cpp/threading/MSThreads.hh(160) : fatal error C1506: unrecoverable block scoping error
出错的代码位于Priority.hh中,代码为:
static const int MESSAGE_SIZE = 8;
这个错误改起来很简单,只要将这行代码改为:
static const int MESSAGE_SIZE;
然后定位到Priority.cpp文件中,添加以下的代码即可:
const int Priority::MESSAGE_SIZE = 8;
注意一下,如果这行代码没有放在namespace中时,需要在加上namespace,如:
const int log4cpp::Priority::MESSAGE_SIZE = 8;
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步