VC6+STLport-5.1.0编译log4cpp-0.3.4b

来源:互联网 发布:js正则表达式判断空格 编辑:程序博客网 时间:2024/05/25 23:25

将VC6的stl库与IOStream替换为2006年底最新发布的STLport-5.1.0后,需要重新编译原来的log4cpp库。
原来的log4cpp库版本为0.3.4b,一直用着,暂时没有升级版本的需要。
(log4cpp最新版本0.3.5rc3要改多处代码才能在VC下编译,感觉不是一个可发布的版本,也没有什么实质性更新。)

不过发现原来通过编译的log4cpp-0.3.4b有编译错误,需要更改才能通过。

* msthreads.cpp(10) : error C2065: 'sprintf' : undeclared identifier
添加 #include <stdio.h>

* patternlayout.cpp(195) : error C2593: 'operator <<' is ambiguous
原因是为了绕过VC6的 operator << __int64 缺陷,自定义'<<',见文件头部。
需要关闭 LOG4CPP_MISSING_INT64_OSTREAM_OP 宏定义来禁止自定义。
搜索到:config-win32.h(23):#define LOG4CPP_MISSING_INT64_OSTREAM_OP
将其注释掉。

* rollingfileappender.cpp(73) : error C2065: 'SEEK_END' : undeclared identifier
添加 #include <stdio.h>

现在编译是通过了,不过还有一个Bug,应该是STLport的Bug。
RollingFileAppender.cpp(62):
                oldName.seekp(n, std::ios::beg);

在log4cpp0.3.5rc3中为STLport作如下补丁(不知为什么STLport-5.1.0还未作修正):

#ifndef LOG4CPP_STLPORT_AND_BOOST_BUILD
                oldName.seekp(static_cast<std::ios::off_type>(n), std::ios::beg);
#else
                // the direction parameter is broken in STLport 4.5.3,
                // so we don't specify it (the code works without it)
                oldName.seekp(n);
#endif

直接改为:
                oldName.seekp(n);
就好了。
原创粉丝点击