错误处理--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;