錯誤處理--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;