Tag Archives: C++11
C++ - The value of ESP was not properly saved across a function call
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Another run time error that is almost impossible to quickly identify and debug. It usually occurs when libraries are involved and use different calling conventions e.g. _stdcall instead of _cdecl or other. But sometimes compiler misses a thing or two and compiles something that it shouldn't, after all, compiler only need to know how many bits and bytes to move and what do to with them to translate your program to an executable or a library. Sometimes it lets you do stupid things...
Continue reading →
C++ - everything to know about Time and Timers
For years, since 1983 when C++ was first released, developers were stuck with C time library, packed in ctime header file. It contains a couple of functions and precision up to a second sometimes just isn't enough. For everything else clock() should be used or OS (Operating System) provided function, which really breaks code portability. In C++11 things got much better, with Chrono module.
Continue reading →
C++ Lambda Expressions
C++ is currently going through some extensive updates started with the new C++11 standard back in 2011. One of the exciting and very powerful new features are anonymous functions also knows as lambdas. You can simply write them inline in your source code and pass them around as function pointers. An example of sorting vector of ints in a descending order:
vector<int> vec = { 10, 1, 5, 6, 7, 3, 5 };
sort(vec.begin(), vec.end(), [](int x, int y) { return x < y; });
Continue reading →