不能在VS2013中使用
Opened this issue · 8 comments
虽然VS2013没有完整的支持C++11,cplusplus_14.h里面对VS2013的兼容没有起到作用,很多constexptr也不能使用,作者还会支持VS2013吗?
问题应该不大,我好奇的是为啥不升级msvc呢,13都是10年前的版本了,很老了。
我们的用户都是传统的国企,甚至还有人在用vs2010,更有甚者有的部门居然在用vc6开发,希望能用上您的库,谢谢!!!
能把具体的编译错误贴出来看看吗?
vs2013中不支持constexpr,根据网上的说法替换成const后,编译example client 报如下错误:
1>------ Rebuild All started: Project: client, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(11): error C2039: 'index_sequence' : is not a member of 'std'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(11): error C2061: syntax error : identifier 'index_sequence'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(10): error C3547: template parameter 'Idx' cannot be used because it follows a template parameter pack and cannot be deduced from the function parameters of 'rest_rpc::for_each'
1> c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(9) : see declaration of 'Idx'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(17): error C2039: 'index_sequence' : is not a member of 'std'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(17): error C2061: syntax error : identifier 'index_sequence'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(16): error C3547: template parameter 'Idx' cannot be used because it follows a template parameter pack and cannot be deduced from the function parameters of 'rest_rpc::for_each_i'
1> c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(15) : see declaration of 'Idx'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(82): error C2039: 'index_sequence' : is not a member of 'std'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(82): error C2065: 'index_sequence' : undeclared identifier
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(82): error C2143: syntax error : missing ')' before '...'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(82): error C2059: syntax error : ')'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(89): error C2143: syntax error : missing ';' before '{'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(89): error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(96): error C2039: 'index_sequence' : is not a member of 'std'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(96): error C2061: syntax error : identifier 'index_sequence'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(112): error C2039: 'tuple_element_t' : is not a member of 'std'
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(112): error C2061: syntax error : identifier 'tuple_element_t'
原因是vs2013中没有index_sequence的定义,cplusplus_14.h有这个定义,但是不好使,不熟悉模板,不知道这块怎么改,谢谢!
把 #if __cplusplus == 201103L 改成 #if _MSC_VER == 1800后,删除noexcept【vs2013不支持】,再次编译example客户端代码报错如下:
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\cplusplus_14.h(63): error C2386: 'enable_if_t' : a symbol with this name already exists in the current scope
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\cplusplus_14.h(65): error C2386: 'remove_const_t' : a symbol with this name already exists in the current scope
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\cplusplus_14.h(68): error C2386: 'remove_reference_t' : a symbol with this name already exists in the current scope
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\cplusplus_14.h(73): error C2386: 'decay_t' : a symbol with this name already exists in the current scope
1>c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(35): fatal error C1903: unable to recover from previous error(s); stopping compilation
1> c:\users\administrator\desktop\rest_rpc\include\rest_rpc\meta_util.hpp(43) : see reference to class template instantiation 'rest_rpc::function_traits<Ret(Arg,Args...)>' being compiled
拉一下最新代码试一下。
还是不行,在一些编译错误的文件中,我增加了
#if MSC_VER < 1900
#define constexpr const
#define noexcept
#endif
解决了2013不支持constexpr和noexcept的问题,
通过在构造函数中初始化的方式解决了
std::atomic_bool has_connected = {false};的编译错误;
但是再次编译还是提示:
error C2248: 'msgpack::v1::sbuffer::sbuffer' : cannot access private member declared in class 'msgpack::v1::sbuffer'
这好像是因为msgpack兼容2013的问题
换新版本的msvc吧