I attempted to try out co_await as mentioned in this article https://blogs.msdn.microsoft.com/vcblog/2016/04/04/using-c-coroutines-to-simplify-async-uwp-code/ but there are weird compilation errors:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\experimental\resumable(44,0): Error C2825: '_Ret': must be a class or namespace when followed by '::' (compiling source file MainPage.xaml.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\experimental\resumable(44): error C2825: '_Ret': must be a class or namespace when followed by '::' (compiling source file MainPage.xaml.cpp)
MainPage.xaml.cpp(44): note: see reference to class template instantiation 'std::experimental::coroutine_traits<void,::MainPage ^,Windows::UI::Xaml::Navigation::NavigationEventArgs ^>' being compiled
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\experimental\resumable(44,0): Error C2510: '_Ret': left of '::' must be a class/struct/union (compiling source file MainPage.xaml.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\experimental\resumable(44): error C2510: '_Ret': left of '::' must be a class/struct/union (compiling source file MainPage.xaml.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\experimental\resumable(44,0): Error C2061: syntax error: identifier 'promise_type' (compiling source file MainPage.xaml.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\experimental\resumable(44): error C2061: syntax error: identifier 'promise_type' (compiling source file MainPage.xaml.cpp)
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\experimental\resumable(44,0): Error C2238: unexpected token(s) preceding ';' (compiling source file MainPage.xaml.cpp)
Originally, I put the following code in the constructor
#include <experimental\resumable>
#include <pplawait.h>
using namespace concurrency;
MainPage::MainPage()
{
InitializeComponent();
auto my_data_file = co_await Windows::ApplicationModel::Package::Current->InstalledLocation->GetFileAsync("samples.txt");
// Preparing app data structures
}
which does not work. My guess is that this is not possible in constructor (for obvious reason) so I move the co_await line to
void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
{
auto my_data_file = co_await Windows::ApplicationModel::Package::Current->InstalledLocation->GetFileAsync("samples.txt");
}
which result in the aforementioned compilation errors.
My guess is that the first problem is that you can't return void from a resumable function since void does not fill any coroutine traits that co_await expect (like get_return_object , set_result etc.)
if you are already using PPL, return task<void>:
task<void> MainPage::OnNavigatedTo(NavigationEventArgs^ e)
{
auto my_data_file = co_await Windows::ApplicationModel::Package::Current->InstalledLocation->GetFileAsync("samples.txt");
}
I found the answer: co_await can only be used if we are returning a task<> (this is incorrect, see #DavidHaim's answer). I guess it is just a syntactic sugar for create_task. The solution is to extract a method returning task<void> in this case:
#include <experimental\resumable>
#include <pplawait.h>
using namespace concurrency;
MainPage::MainPage()
{
InitializeComponent();
PrepareData();
}
task<void> MainPage::PrepareData()
{
auto my_data_file = co_await Windows::ApplicationModel::Package::Current->InstalledLocation->GetFileAsync("samples.txt");
// Preparing app data structures
}
Some comment: Although the coroutine feature looks nice, it pollutes the language. Observe that the body of PrepareData() does NOT have any return statement but the signature says it returns task<void>, leading to my failure to recognize the requirement in the article.
Related
This question already has answers here:
std::map::reverse_iterator doesn't work with C++20 when used with incomplete type [duplicate]
(1 answer)
map with incomplete value type
(1 answer)
std::variant and incomplete type: how does it work?
(1 answer)
Closed 4 months ago.
I would like to understand why, using Visual Studio 2019 or 2022, the following code compiles with the a and b variables but not with the c variable. Is there any workaround for this issue?
#include <variant>
#include <vector>
struct data; // defined in another file
std::variant<data>* a; // ok
std::vector<data*> b; // ok
std::vector<std::variant<data>*> c; // error C2139: 'data': an undefined class
// is not allowed as an argument to
// compiler intrinsic type trait
// '__is_trivially_destructible'
The complete error message is:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(931,60): error C2139: 'data': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_trivially_destructible'
1>C:\Temp\test2019\main.cpp(4): message : see declaration of 'data'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(931): message : see reference to variable template 'const bool conjunction_v<std::is_trivially_destructible<data> >' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(1006): message : see reference to alias template instantiation 'std::_Variant_destroy_layer<data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1667): message : see reference to class template instantiation 'std::variant<data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1665): message : while compiling class template member function 'void std::vector<std::variant<data> *,std::allocator<std::variant<data> *>>::_Destroy(std::variant<data> **,std::variant<data> **)'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1751): message : see reference to function template instantiation 'void std::vector<std::variant<data> *,std::allocator<std::variant<data> *>>::_Destroy(std::variant<data> **,std::variant<data> **)' being compiled
1>C:\Temp\test2019\main.cpp(8): message : see reference to class template instantiation 'std::vector<std::variant<data> *,std::allocator<std::variant<data> *>>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(60,19): error C2139: 'data': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_constructible'
1>C:\Temp\test2019\main.cpp(4): message : see declaration of 'data'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(60): message : see reference to variable template 'const bool conjunction_v<std::is_move_constructible<data>,std::negation<std::conjunction<std::is_trivially_move_constructible<data> > > >' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(97): message : see reference to alias template instantiation 'std::_SMF_control_move<std::_Variant_destroy_layer_<data>,data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(39,19): error C2139: 'data': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_constructible'
1>C:\Temp\test2019\main.cpp(4): message : see declaration of 'data'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(39): message : see reference to variable template 'const bool conjunction_v<std::is_copy_constructible<data>,std::negation<std::conjunction<std::is_trivially_copy_constructible<data> > > >' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(61): message : see reference to alias template instantiation 'std::_SMF_control_copy<std::_Variant_destroy_layer_<data>,data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(462,32): error C2079: 'std::_Variant_storage_<false,data>::_Head' uses undefined struct 'data'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(810): message : see reference to class template instantiation 'std::_Variant_storage_<false,data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(916): message : see reference to class template instantiation 'std::_Variant_base<data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(82): message : see reference to class template instantiation 'std::_Variant_destroy_layer_<data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xsmf_control.h(120): message : see reference to class template instantiation 'std::_Deleted_copy_assign<std::_Variant_destroy_layer_<data>,data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(1006): message : see reference to class template instantiation 'std::_Deleted_move_assign<std::_Variant_destroy_layer_<data>,data>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(1008,86): error C2139: 'data': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_destructible'
1>C:\Temp\test2019\main.cpp(4): message : see declaration of 'data'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(1008): message : see reference to variable template 'const bool conjunction_v<std::is_object<data>,std::negation<std::is_array<data> >,std::is_destructible<data> >' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\variant(1008,19): error C2338: variant<Types...> requires all of the Types to meet the Cpp17Destructible requirements N4828 [variant.variant]/2.
I am trying to use std::upper_bound with a vector defined by the Eigen libraries. I get some errors on visual studio 2017
#include <stdafx.h>
#include <stdio.h>
#include <Eigen/Dense>
#include <algorithm>
using namespace Eigen;
using namespace std;
int main(int argc, char* argv[])
{
VectorXd myVector= VectorXd::LinSpaced(20, -1.5, 6.4);
double trashold= strtod(argv[1], NULL);
double firstGreaterValue= std::upper_bound(myVector(0),
myVector(myVector.size()-1),trashold);
}
I expect the program to return the position of the first element that is greater than my input (that in this case is 1.1).
I get these errors on compiling
Severity Code Description Project File Line Suppression State
Error C2794 'difference_type': is not a member of any direct or indirect base class of 'std::iterator_traits<_FwdIt>' errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2347
Error C2938 '_Iter_diff_t<double>' : Failed to specialize alias template errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2347
Error C2672 'std::distance': no matching overloaded function found errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2347
Error C2893 Failed to specialize function template 'iterator_traits<_Iter>::difference_type std::distance(_InIt,_InIt)' errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2347
Error C2794 'difference_type': is not a member of any direct or indirect base class of 'std::iterator_traits<_FwdIt>' errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2351
Error C2938 '_Iter_diff_t<double>' : Failed to specialize alias template errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2351
Error C2672 'std::advance': no matching overloaded function found errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2353
Error C2893 Failed to specialize function template 'void std::advance(_InIt &,_Diff)' errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2353
Error C2100 illegal indirection errorExample C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\algorithm 2355
Until Version 3.4, Eigen::VectorXd is not compatible with STL algorithms since it does not provide iterators to access its elements.
Since Version 3.4, Eigen's dense matrices and arrays provide STL compatible iterators, then you can use begin()/end() method to get the iterator:
auto firstGreaterValueIter = std::upper_bound(myVector.begin(), myVector.end(), trashold);
Also don't forget std::upper_bound returns an iterator, so you must dereference to get the value:
if (firstGreaterValueIter != myVector.end()) {
double firstGreaterValue = *firstGreaterValueIter;
// ...
}
Have the following code which compiles and runs fine in Visual C++ 2013, and the C++14 standard on http://cpp.sh. However, on Visual C++ 2017 ( ver 15.9.3 ), it gives an error message... which is maybe a bug?
Code is:
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
vector<long> v1 = {1}, v2 = {9};
swap<vector<long>>(v1, v2);
cout << "v1.front(): " << v1.front() << endl;
cout << "v2.front(): " << v2.front() << endl;
return 0;
}
I should note that if I comment out swap() function, then it compiles and runs ok. The error messages are all resulting from the call to swap().
Error messages are:
maptest.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2048): error C2039: '_Alloc': is not a member of 'std::vector<long,std::allocator<_Ty>>'
with
[
_Ty=long
]
maptest.cpp(9): note: see declaration of 'std::vector<long,std::allocator<_Ty>>'
with
[
_Ty=long
]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2096): note: see reference to class template instantiation 'std::_Vb_iter_base<_Alvbase_wrapped>' being compiled
with
[
_Alvbase_wrapped=std::vector<long,std::allocator<long>>
]
maptest.cpp(11): note: see reference to class template instantiation 'std::_Vb_reference<std::vector<long,std::allocator<_Ty>>>' being compiled
with
[
_Ty=long
]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2048): error C2061: syntax error: identifier '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2065: '_Alvbase': undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2923: 'std::allocator_traits': '_Alvbase' is not a valid template type argument for parameter '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2955: 'std::allocator_traits': use of class template requires template argument list
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xmemory0(903): note: see declaration of 'std::allocator_traits'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2039: 'size_type': is not a member of 'std::allocator_traits<_Alloc>'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2061: syntax error: identifier 'size_type'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2065: '_Alvbase': undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2923: 'std::allocator_traits': '_Alvbase' is not a valid template type argument for parameter '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2955: 'std::allocator_traits': use of class template requires template argument list
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xmemory0(903): note: see declaration of 'std::allocator_traits'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2039: 'difference_type': is not a member of 'std::allocator_traits<_Alloc>'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2061: syntax error: identifier 'difference_type'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2051): error C2065: '_Alvbase': undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2051): error C2923: 'std::_Rebind_alloc_t': '_Alvbase' is not a valid template type argument for parameter '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2058): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2065): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2072): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2089): error C3646: '_Myoff': unknown override specifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2089): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
std::swap is overloaded for std::vector as
template< class T, class Alloc>
void swap(vector<T,Alloc>& lhs, vector<T,Alloc>& rhs);
The correct template arguments for your given vector would be T=long, Alloc = std::allocator<long>. The proper way to call swap (or almost any other templated function) on an std::vector is to simply drop the explicit template argument specification altogether and let template argument deduction do its work.
I'm having a weird error when trying to use 'QJsonObject::iterator' with MSVC2013.
I have the following example:
#include <QCoreApplication>
#include <QJsonObject>
#include <QDebug>
#include <algorithm>
void processValue(QJsonValue value) {
qDebug() << value.toString();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QJsonObject jsonObject;
jsonObject.insert("a", "A");
jsonObject.insert("b", "B");
jsonObject.insert("c", "C");
jsonObject.insert("d", "D");
jsonObject.insert("e", "E");
std::for_each (jsonObject.begin(), jsonObject.end(), processValue);
return a.exec();
}
This code compiles and works as expected with MSVC2008 (cross-compiling to WinCE) and MinGW, but not with MSVC2013. In all cases, I'm using Qt 5.5.1.
The error message is:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xutility(375) : error C2039: 'pointer' : is not a member of 'QJsonObject::iterator'
c:\qt\qt5.5.1msvc\5.5\msvc2013\include\qtcore\qjsonobject.h(96) : see declaration of 'QJsonObject::iterator'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xutility(584) : see reference to class template instantiation 'std::iterator_traits<_InIt>' being compiled
with
[
_InIt=QJsonObject::iterator
]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\algorithm(31) : see reference to function template instantiation 'void std::_Debug_range<_InIt>(_InIt,_InIt,std::_Dbfile_t,std::_Dbline_t)' being compiled
with
[
_InIt=QJsonObject::iterator
]
..\QJsonObjectIteratorIssue\main.cpp(21) : see reference to function template instantiation '_Fn1 std::for_each<QJsonObject::iterator,void(__cdecl *)(QJsonValue)>(_InIt,_InIt,_Fn1)' being compiled
with
[
_Fn1=void (__cdecl *)(QJsonValue)
, _InIt=QJsonObject::iterator
]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xutility(375) : error C2146: syntax error : missing ';' before identifier 'pointer'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xutility(375) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xutility(375) : error C2602: 'std::iterator_traits<_InIt>::pointer' is not a member of a base class of 'std::iterator_traits<_InIt>'
with
[
_InIt=QJsonObject::iterator
]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xutility(375) : see declaration of 'std::iterator_traits<_InIt>::pointer'
with
[
_InIt=QJsonObject::iterator
]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xutility(375) : error C2868: 'std::iterator_traits<_InIt>::pointer' : illegal syntax for using-declaration; expected qualified-name
with
[
_InIt=QJsonObject::iterator
]
Am I doing anything wrong here, that just happen to work by chance on the 2 other compilers?
Use 5.6 or backport this: https://code.qt.io/cgit/qt/qtbase.git/commit/?id=4a318a61824216ac499ff8b0b0c55dea90501005
QJsonObject::(const_)iterator: add pointer typedef
Otherwise they're unusable with std::algorithms or anything else
that requires iterator_traits.
i'm trying to integrate the SymbolicC++ Library into an already existing solution. My specifications are as followed: Visual Studio 2010 RTM on a Windows 7 OS.
Now my problem:
I already have a solution where I want to integrate a function with symblic variables. There is another previously integrated library (The OMPL "Open Motion Planning Library). If i try to include the symbolicc++.h it fails to compile the solution by these errors:
Error 10 error C2825: '_Fty': must be a class or namespace when followed by '::' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 28`
Error 11 error C2903: 'result' : symbol is neither a class template nor a function template c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 28
Error 12 error C2039: 'result' : is not a member of '`global namespace'' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 28
Error 13 error C2143: syntax error : missing ';' before '<' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 28
Error 14 error C2039: 'type' : is not a member of '`global namespace'' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 28
Error 15 error C2238: unexpected token(s) preceding ';' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 28
Error 16 error C2039: '_Type' : is not a member of 'std::tr1::_Result_type2<__formal,_Fty,_Arg0,_Arg1>' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 40
Error 17 error C2146: syntax error : missing ';' before identifier '_Type' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 40
Error 18 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 40
Error 19 error C2602: 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>::_Type' is not a member of a base class of 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>' c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 40
Error 20 error C2868: 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>::_Type' : illegal syntax for using-declaration; expected qualified-name c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxresult 40
Error 21 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::tr1::_Bind_fty<_Fty,_Ret,_BindN>' (or there is no acceptable conversion) D:\Software\RobotKitV3.0\SensorPluginMotionPlanner\Zusatz\ompl_4_RK\RK_ServerSensor_ompl\RK_ServerSensor_ompl\ServerSensor_ompl.cpp 2587
I am quite sure there is some issue between the two libraries. But i'm not getting it to work properly.
There is one line (which is referred to the Error 21), when I change it from this:
if(bind(serverSocket, (sockaddr*) &addressServer, sizeof(addressServer)) == SOCKET_ERROR)
To this:
if(::bind(serverSocket, (sockaddr*) &addressServer, sizeof(addressServer)) == SOCKET_ERROR)
I don't have these errors anymore! But when i try to start the .exe it fails
with this error:
The application was unable to start correctly (0xc000007b). Click OK to close the application
unless i exclude the line:
#include <symbolicc++.h>
Has somebody an idea to get this work? It's so frustrating that i try to implement the symbolicc++.h since 5 days and can't execute my solution.
Edit:
So I made some progress. If I just comment out everything except this code below there is no error anymore.
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <winsock.h>
#include <fstream>
#include <iostream>
#include <string>
#include <WinBase.h>
#include "..\..\SymbolicC++\include\symbolicc++.h"
#include "ServerSensor_ompl.h"
#include <ompl/base/SpaceInformation.h>
#include <ompl/base/spaces/SE3StateSpace.h>
#include <ompl/base/spaces/SE2StateSpace.h>
#include <ompl/base/spaces/SO2StateSpace.h>
#include <ompl/geometric/planners/rrt/RRTConnect.h>
#include <ompl/geometric/SimpleSetup.h>
#include <ompl/config.h>
#include <ompl/geometric/planners/rrt/RRT.h>
#include <ompl/geometric/planners/rrt/RRTConnect.h>
#include <ompl/geometric/planners/rrt/RRTStar.h>
Symbolic Test("Test");
namespace ob = ompl::base;
namespace og = ompl::geometric;
namespace ob_Con_WP = ompl::base;
namespace og_Con_WP = ompl::geometric;
namespace ob_Con_RC = ompl::base; // Robot_Cell
namespace og_Con_RC = ompl::geometric; // Robot_Cell
WSADATA wsa;
struct sockaddr_in addressServer;
int commSocket, serverSocket;
bool RK_active = true;
int m_bufferLength = 0;
int m_bufferLength2 = 0;
const size_t BufferSize = 100000;
char m_buffer[BufferSize];
char m_buffer2[BufferSize];
int Trial_Cart = 0;
int Trial_Joint = 0;
int Trial_Constraint_WP = 0;
int Trial_Constraint_RC = 0;
int Trial_General = 0;
bool Have_Exact_Solution;
std::fstream f;
int countCalls = 0;
int countCallLimit = 1000;
double Constraint_Bounds[2][6];
ob::StateSpacePtr space_Joint(new ob::RealVectorStateSpace(6));
ob::StateSpacePtr space_Cart(new ob::SE3StateSpace);
ob_Con_WP::StateSpacePtr space_Constraint_WP(new ob_Con_WP::RealVectorStateSpace(6));
ob_Con_RC::StateSpacePtr space_Constraint_RC(new ob_Con_RC::RealVectorStateSpace(6));
ob_Con_RC::SpaceInformationPtr si(new ob_Con_RC::SpaceInformation(space_Constraint_RC));
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "OMPL version: " << OMPL_VERSION << std::endl;
std::cout << std::endl << std::endl;
system("pause");
}
But for example if I try to put this line below into my code the same error (0xc000007B) occurs when I try to execute.
og::SimpleSetup ss_Cart(space_Cart);