Boost编译器错误
Boost compiler error?
我正在尝试构建这个程序:
#include "stdafx.h"
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>
using namespace std;
int main()
{
using boost::interprocess;
// Create the file mapping
file_mapping fm("input.dat", read_only);
// Map the file in memory
mapped_region region(fm, read_only);
// Get the address where the file has been mapped
float * addr = (float *)region.get_address();
std::size_t elements = region.get_size() / sizeof(float);
}
但我有两个问题,主要是
1>tasker.cpp(98): error C2873: 'boost::interprocess' : symbol cannot be used in a using-declaration
1>tasker.cpp(101): error C2065: 'file_mapping' : undeclared identifier
1>tasker.cpp(101): error C2146: syntax error : missing ';' before identifier 'fm'
1>tasker.cpp(101): error C2065: 'read_only' : undeclared identifier
1>tasker.cpp(101): error C3861: 'fm': identifier not found
1>tasker.cpp(103): error C2065: 'mapped_region' : undeclared identifier
1>tasker.cpp(103): error C2146: syntax error : missing ';' before identifier 'region'
1>tasker.cpp(103): error C2065: 'fm' : undeclared identifier
1>tasker.cpp(103): error C2065: 'read_only' : undeclared identifier
1>tasker.cpp(103): error C3861: 'region': identifier not found
1>tasker.cpp(105): error C2065: 'region' : undeclared identifier
1>tasker.cpp(105): error C2228: left of '.get_address' must have class/struct/union
1> type is 'unknown-type'
1>tasker.cpp(106): error C2065: 'region' : undeclared identifier
1>tasker.cpp(106): error C2228: left of '.get_size' must have class/struct/union
1> type is 'unknown-type'
对于#include <boost/interprocess/mapped_region.hpp>
,我得到
1>C:UsersMikeDocumentsboost_1_55_0boost/intrusive/detail/has_member_function_callable_with.hpp(200): error C2228: left of '.select_on_container_copy_construction' must have class/struct/union
1> type is 'boost::move_detail::add_rvalue_reference<U>::type'
1> C:UsersMikeDocumentsboost_1_55_0boost/intrusive/detail/has_member_function_callable_with.hpp(276) : see reference to class template instantiation 'boost::container::container_detail::has_member_function_callable_with_select_on_container_copy_construction_impl<Fun,true,>' being compiled
1> with
1> [
1> Fun=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1> ]
1> C:UsersMikeDocumentsboost_1_55_0boost/container/allocator_traits.hpp(262) : see reference to class template instantiation 'boost::container::container_detail::has_member_function_callable_with_select_on_container_copy_construction<const Alloc,>' being compiled
1> with
1> [
1> Alloc=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1> ]
1> C:UsersMikeDocumentsboost_1_55_0boost/container/detail/tree.hpp(217) : see reference to class template instantiation 'boost::container::allocator_traits<A>' being compiled
1> with
1> [
1> A=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1> ]
1> C:UsersMikeDocumentsboost_1_55_0boost/container/detail/tree.hpp(246) : see reference to class template instantiation 'boost::container::container_detail::intrusive_rbtree_type<A,boost::container::container_detail::tree_value_compare<Key,std::pair<const Key,T>,Compare,boost::container::container_detail::select1st<std::pair<const Key,T>>>>' being compiled
1> with
1> [
1> A=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1> , Key=const boost::interprocess::ipcdetail::sync_id *
1> , T=boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>
1> , Compare=boost::interprocess::ipcdetail::sync_handles::address_less
1> ]
1> C:UsersMikeDocumentsboost_1_55_0boost/container/map.hpp(83) : see reference to class template instantiation 'boost::container::container_detail::rbtree<Key,std::pair<const Key,T>,boost::container::container_detail::select1st<std::pair<const Key,T>>,Compare,Allocator>' being compiled
1> with
1> [
1> Key=const boost::interprocess::ipcdetail::sync_id *
1> , T=boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>
1> , Compare=boost::interprocess::ipcdetail::sync_handles::address_less
1> , Allocator=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1> ]
1> C:UsersMikeDocumentsboost_1_55_0boost/interprocess/sync/windows/sync_utils.hpp(226) : see reference to class template instantiation 'boost::container::map<const boost::interprocess::ipcdetail::sync_id *,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<T>>,boost::interprocess::ipcdetail::sync_handles::address_less,std::allocator<std::pair<const Key,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<T>>>>>' being compiled
1> with
1> [
1> T=std::pair<const boost::interprocess::ipcdetail::sync_id,void *>
1> , Key=const boost::interprocess::ipcdetail::sync_id *
1> ]
我使用的是适用于Windows桌面的Visual Studio Express 2013和1.55.0版本。
我尝试了其他boost库,工作时没有遇到任何问题。。。。此外,我正在使用x64版本。
Boost 1.55还不完全支持Visual Studio 2013编译器。
任一:
- 使用Visual Studio 2012工具链
- 或尝试从
svn co http://svn.boost.org/svn/boost/trunk boost-trunk
获取最新源 - 或者为自己打补丁(别忘了上传你的补丁)
- 或者等到有人修补它。你可以通过提交错误报告来加快速度
编辑
刚刚检查了boost-trunk
,其中boost/intrusive/detail/has_member_function_callable_with.hpp
已经打过补丁,它可以用vs2013
和vs2013-nov-2013-ctp
工具链进行良好编译。所以,试试吧。如果你有多个提升版本,别忘了像我一样更改包含路径(在Makefile或VC项目属性中)。)
请注意,很明显,最新的开发代码可能是不稳定的。不要将其用于最终用户生产。
尝试更改此项:
using boost::interprocess;
到此:
using namespace boost::interprocess;
(参考:中的示例http://www.boost.org/doc/libs/1_55_0/doc/html/interprocess/quick_guide.html)
是的。您需要说"使用名称空间boost::interprocess;"解决这个问题,你应该会好起来的。
相关文章:
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++,我收到一个无法理解的编译器错误
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- C++错误C2600:无法定义编译器生成的特殊成员函数(必须首先在类中声明)
- 我收到同义重复编译器错误。我应该如何修复"类型"X"的参数与类型"X"的参数不兼容?
- 重载方法的方式会在使用临时调用时生成编译器错误
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- 有没有办法让编译器在我放置字符串而不是 nlohmann::json 对象时抛出错误?
- 致命错误 C1001 :vs2017 15.8.4 的内部错误(编译器文件"msc1.cpp",第
- C++2440错误-编译器认为字符串是常量字符
- Clang 错误 – 编译器错误或缺少一些细节?
- 视觉C++ 2017 错误?编译器优化表达式
- 配置:错误:C++编译器无法创建可执行文件
- PHP PDO_ODBC配置:错误:C 编译器无法创建可执行文件
- 致命错误 C1001:内部编译器错误(编译器文件"MSC1.cpp",第 1794 行)
- 错误:编译器限制达到简单hello world程序的堆限制
- c++链接错误:编译器找不到函数的定义
- 生成 CImg 时出现致命错误(编译器限制)
- 抛出对齐类型时出现 Clang 运行时错误.编译器错误