码迷,mamicode.com
首页 > 其他好文 > 详细

log4cxx,vs2013/vs2010编译 c2252错误

时间:2015-04-15 16:47:00      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:

换编译器编译和使用log4cxx时遇到c2252错误

 

error C2252: an explicit instantiation of a template can only occur at namespace scope

 

搜索了一下解决方案,在log4cxx邮件列表有如下关于该bug解决方案的描述:

 

Hi Cory,

This is how I did it:

1. Move all those LOG4CXX_LIST_DEF macros before the class definition.

in telnetappender.h you will also need to move the typedef that precedes this 
macro.

2. If the compiler complains about KeySet not being member of LoggingEvent, 
just remove the scope (since we moved the type to outside the class in the 
previous step, these types no longer are inside the class)
ex: 
change: LoggingEvent::KeySet set;
to: KeySet set;

3. If the compiler complains about insert_iterator not being in the namespace 
std, add
#include <iterator>
to the include section of the source file

4. For some reason the VS2010 converter ‘forgot‘ to reference the lib files 
from apr,apr-util and xml, so i had to add them manually.

Hope it helps,

Daniel


我采取了一个比较简单粗暴的方式解决这个问题:
在loggingevent.h中用

typedef std::vector<LogString> KeySet;

替换

//LOG4CXX_LIST_DEF(KeySet, LogString);

 




log4cxx,vs2013/vs2010编译 c2252错误

标签:

原文地址:http://www.cnblogs.com/zstang/p/4428744.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!