Experimenting with threads priority C++ - c++

i'm attempting to execute the code given as example here : https://en.cppreference.com/w/cpp/thread/thread/native_handle
But when i compile it in Visual Studio 2017 on Windows 10 x64 machine
i have this error
E0415 no constructor exists for converting "std::thread::native_handle_type" to "ptw32_handle_t"
I simply copied the code.... where i'm wrong ?
Tnx, Fabio.

Related

run error xmemory() with function findchessboardcorners()?

I am using OpenCV and MS Visual Studio 2013 to simply detect chessboard. It compiles and build all fine but gives a runtime error in xmemory0() file located in:
c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xmemory0
I just cant seem to understand the problem. Any thought would be appreciated.
The debugger breaks in xmemory0(), I thought that the problem in findChessboardCorners() function and library opencv-core2410. I tried same function with vs2010 and it works, but I need to do it with vs2013.
After hard work i found that i must determine the size of cv::vector variables before use it, for example:
cv::vector<Point2f> corners;
corners.resize(54);
bool patternfound = findChessboardCorners(gray, patternsize, corners,CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE);
I didn't need to resize vector in vs2010 but just in vs2013.

How to solve error C2719 in visual studio 2010 when compiling a cpp generated by cython

I'm trying to install a python module to use the PCL library (wrote in C++ and using the Eigen library) following this procedure : https://github.com/strawlab/python-pcl
Unfortunately when I'm trying to build the septup file I get the C2719 error (see screenshoot for detail). png
The line code causing the error is the following :
__pyx_vtable_3pcl_4_pcl_OctreePointCloudSearch._VoxelSearch = (void (*)(struct __pyx_obj_3pcl_4_pcl_OctreePointCloudSearch *, struct pcl::PointXYZ, std::vector<int> &))__pyx_f_3pcl_4_pcl_22OctreePointCloudSearch__VoxelSearch;
(for detail code see https://pastebin.com/W0m9wzzc)
After reading about this : https://ofekshilon.com/2010/05/05/stdvector-of-aligned-elements/
I understand that i have to adapt the syntax of the code to make it explicit that objects are aligned on a 16 byte boundaries.
My issue is clearly of the same kind of that one : How to solve error C2719 in visual studio 2010 c++ when no code line exist in code
I can more or less assume that the part of the code causing the problem is related to struct pcl::PointXYZ, std::vector<int> &)
Unfortunately I'm completely new to C++ and I do not really understand what the code is doing, thus I'm unable to adapt it to make it work.
Help would be greatly appreciate :)
spec:
Cython 0.25.2
PCL 1.6
VS 2010

Visual studio 2015 . How to *not* step in certain functions?

I'd like to configure the VS2015 debugger so that when I'm stepping in into some code (F11), it steps through certain functions .
For example, let's say there is a template class SmartPointer which has an overloaded member -> .
If I have the following statement :
SmartPointer<SomeClass> ptr;
/* initialize ptr */
ptr->method();
The debugger will step into SmartPointer::operator->, exit, then the into method().
I'd like to directly step into method().
Is this possible ?
EDIT : The so called duplicate isn't one because it doesn't work with vs2013 or 2015
Ok I actually found the solution. You have to edit as an administrator:
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\Packages\Debugger\Visualizers\default.natstepfilter
or
C:\Program Files\Microsoft Visual Studio
14.0\Common7\Packages\Debugger\Visualizers\default.natstepfilter
depending if you're under a 64 or 32 bit machine. The add a line like
<Function><Name>SomeFunction</Name><Action>NoStepInto</Action></Function>
HTH

C++11 constexpr causes compiler's internal error (C1001)

I am using Visual Studio 2015 Update 3.
I get a fatal error:
(code C1001) : An internal error has occurred in the compiler.
Here is the code :
template<typename T>
constexpr T epsilon = std::numeric_limits<T>::epsilon();
I read it was fixed in Visual Studio Update 2. Can someone explain me why I am getting this error? Thanks in advance.
Any internal error (ICE) is a compiler bug. You get it because you have happened to trigger that bug. For this compiler you can report it at Microsoft Connect.
For such a report you need an example with an expected correct result, and the erroneous result.
The following test program compiles & runs nicely with MinGW g++ 5.1
#include <limits>
template<typename T>
constexpr T epsilon = std::numeric_limits<T>::epsilon();
#include <iostream>
using namespace std;
auto main() -> int
{
cout << epsilon<double> << endl;
}
Output:
2.22045e-016
With Visual C++ 2015 update 2 it produces an ICE:
foo.cpp(10): fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\symbols.c', line 28114)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
foo.cpp(10): note: see reference to variable template 'const double epsilon' being compiled
Compiler version:
> cl /nologo- 2>&1 | find "++"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23725 for x86
I've raised this as a bug with Microsoft, but they have had a fix since early 2017 which has not been released from what I can see as of today.
I've also provided a project on GitLab and given information to Microsoft for this project here: https://gitlab.com/cppocl/tostring
Loading the .sln and compiling currently crashes with Visual Studio 2015 update 2 or 3, and Visual Studio Enterprise 2017 version 15.3.1.
It does seem that the combination of template and constexpr causes the compiler to crash.
I've seen reports for Visual Studio 2017 describing similar types of problems.
This link says fixed pending release:
https://developercommunity.visualstudio.com/content/problem/18155/msvc-2017-c-fatal-error-c1001-constexpr-initializa.html
Visual Studio 2015 backlog of bugs relating to constexpr is here:
https://blogs.msdn.microsoft.com/vcblog/2015/12/02/constexpr-in-vs2015-update-1/
EDIT:
I also don't believe changing optimization settings will make any difference, as has been recommended in other posts.
I have experimented with these settings and applied recommended patches without success so far.

Smart pointer: runtime crash in VS 9 running WinXP-Sp3

I am getting run time crash in the following piece of code and not able to debug also. Please review and let me know what's going on.
// CppConsole.cpp : Defines the entry point for the console application.
//#include "stdafx.h"#include <iostream>#include <assert.h>
class Test : public std::tr1::enable_shared_from_this<Test>
{
public:
Test():x(0),y(0),z(0){};
int x;
float y;
double z;
};
int _tmain(int argc, _TCHAR* argv[])
{
std::tr1::shared_ptr<Test> t1(new Test);
std::tr1::shared_ptr<Test> t2 = t1->shared_from_this();
return 0;
}
I have include all the headers and the program is compiling fine. This is the error i am getting:
CppConsole.exe - Entry Point Not Found The procedure entry point
?_Xweak#tr1#std##YAXXZ could not be located in the dynamic link
library MSVCP90D.dll
If I comment out this line
std::tr1::shared_ptr t2 = t1->shared_from_this();
the program runs without crashing.
Update: Question can be closed for now. I will try to install VS feature pack and see weather the program executes without any crashes.
Googled it (The procedure entry point ?_Xweak),found this : http://blog.nilretain.org/
EDIT : I Build and Run it successfully on my msvc 2008 on xp-sp3 ,which has later version of msvcp90d.dll.
Maybe you can download and install the latest redist-version of msvc90 and rebuild.
EDIT: your dependencies says something is missing. check this out :
http://answers.yahoo.com/question/index?qid=20090623140325AAInugo
You need a template argument:
std::tr1::shared_ptr<Test> t1(new Test);
std::tr1::shared_ptr<Test> t2 = t1->shared_from_this();
The compiler should report an error if it is not present. (Visual C++ 2010 does)
It appears that your compiler is not linking against a DLL with the needed runtime functions. For instance, if you added the headers to your include path, but don't link to the latest version of the C++ runtime (check your project's settings), or installing the Visual C++ 2008 feature pack didn't work, or you installed the feature pack but then tried to compile from Visual Studio 2005, etc.
Basically the "process the source code (including headers)" step is working fine, but the "link all the DLLs" step is failing. And it's failing because the runtime you're linking against doesn't have the needed functions for shared_ptrs or weak_ptrs.
I had this problem when developing under M$ Windows SP3 with M$ Visual Studio 2008. I tried and combined many hints that I could find on the web. To no avail. The solution was simple, I had to install SP1 pack for M$ Visual Studio 2008!
The thing is that my external DLLs used C++ TR1 functions that I was not aware of. The M$ Visual Studio 2008 without SP does not have the right runtime DLLs.
So, just make sure you have that SP1 for your M$ Visual Studio 2008 first before trying any other solution.