编译boost date_time
来源:互联网 发布:帝国时代 知乎 编辑:程序博客网 时间:2024/05/17 23:12
boost当前最新版本:1.47.0
分别在vs2005和bcb 6下编译.
.vs2005下可用
.bcb 6编译出错
1.下载:
下载位置:www.boost.org
文件名:boost_1_47_0.zip
解压下载的文件:以下用$BOOST_HOME表示解压的主目录
2.生成bjam.exe文件,该文件是用来编译boost的程序
.cd $BOOST_HOME
.booststrap.bat
在当前目录下生成bjam.exe(还有b2.exe)
3.编译
.cd $BOOST_HOME\libs\date_time\build
3.1 vs2005编译
..\..\..\bjam toolset=msvc--build-dir=e:\boost_build_vc
生成的lib/dll位于目录e:\boost_build_vc\boost\bin.v2\libs\date_time\build\msvc-8.0\debug\threading-multi下。
3.2 Borland C++(version:5.6.4)编译
..\..\..\bjam toolset=borland--build-dir=e:\boost_build_bcb
报编译错误:
Error E2034..\..\..\boost/type_traits/add_rvalue_reference.hpp 56: Cannot convert'is_void<T>::value' to 'bool'
对应的代码位置(boost\type_traits\add_rvalue_reference.hpp):
template <typename T>
struct add_rvalue_reference_imp
{
typedef typename boost::type_traits_detail::add_rvalue_reference_helper
<T,(!is_void<T>::value && !is_reference<T>::value) >::typetype; ///< 此行错误
};
可能是由于编译器不支持,见以下链接的相关说明:
http://www.boost.org/doc/libs/1_31_0/more/int_const_guidelines.htm
Don't use logical operators in integral constant expressions; use template meta-programming instead.
The header <boost/type_traits/ice.hpp> contains a number of workaround templates, that fulfil the role of logical operators, for example instead of:
INTEGRAL_CONSTANT1 || INTEGRAL_CONSTANT2
Use:
::boost::type_traits::ice_or<INTEGRAL_CONSTANT1,INTEGRAL_CONSTANT2>::value
4.资源:
(1)http://www.boost.org
boost的官方站点
(2)http://bcbboost.sourceforge.net
提供boost对bcb各个版本支持的测试结果和补丁.
从测试报告看,boost的许多库都不支持bcb.新版本的测试已不对bcb 5.6.4进行了.
5.测试代码
针对bcb 5.6.4下出现的问题,验证诊断的原因:add_rvalue_reference_imp不符合关于以下在模板中使用常量表达式的规范:
Don't use logical operators in integralconstant expressions; use template meta-programming instead.
用测试代码在bcb 6环境下测试:
#include "boost/type_traits/is_void.hpp"
using namespace boost;
template <typename T,int>
struct test_template_1 {
T value;
};
template <typename T>
struct test_template_2
{
// typedef typename test_template_1<T, !(int)is_void<T>::value&&is_void<T>::value > type; ///< 仿add_rvalue_reference_imp
///< 以下是测试的3种情况:
typedef typename test_template_1<T, (bool)1&&1 > type; ///< ok
typedef typename test_template_1<T, is_void<T>::value&&1 > type; /// error
typedef typename test_template_1<T, is_void<T>::value+1 > type; /// ok
};
可以认为是bcb编译器的原因.并且从add_rvalue_reference_imp的代码结构看,似乎也没有合适的宏能够帮助解决此问题.
初步结论:如果要在bcb上使用boost date_time,则需要升级bcb.
- 编译boost date_time
- boost.date_time
- date_time boost
- boost date_time使用
- boost::date_time之时间处理
- Boost库使用----date_time类库
- 修改Boost.date_time代码兼容VC6
- Boost库中date_time库介绍
- 服务端统一时间戳 boost::date_time UTC
- boost库学习之 date_time库
- Boost之日期时间处理(date_time库)
- 深入浅出学习boost的date_time库(一 )
- 被boost的date_time库郁闷了一把
- 《Boost程序完全开发》跟踪学习训练一:Boost::date_time库的使用
- cannot find the flags to link with Boost date_time 错误修复
- boost完全开发指南第2章-处理时间5 (date_time库简单运用)
- Boost库学习随记二 date_time、time_duration、date_facet、time_facet、timer库示例等:
- 编译BOOST
- Android进程间通信--消息机制及IPC机制实现
- 解决Oracle11g_TNSListener自动停止问题
- 用PHP和XML备份MySQL数据库
- 用PHP工具包expat解析XML
- PHP中的字符串函数说明
- 编译boost date_time
- PHP的XML分析函数
- Eclipse MyEclipse Code Template 设置
- SQL导出到MYSQL
- 精妙SQL语句介绍
- 创新工场O2O项目布丁六款生活类应用简评
- SQL Server 6.5 配置使用要点
- 在O(1)时间内返回栈的最小值
- 解决MSSQL占用过多内存的简单方法