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

相关文章:

  • 2022-12-23
  • 2021-07-25
  • 2021-12-12
  • 2022-12-23
  • 2021-12-29
  • 2021-06-20
  • 2022-02-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2021-09-07
  • 2021-05-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案