-
Making HTTP REST Request in C++ With WinHTTP
WinHTTP Wrapper The example code is hosted at Github. The WinHTTP Wrapper consists of one main class that is HttpRequest class. In its constructor, the following parameters: user_agent, proxy_username, proxy_password, server_username and server_password are optional. When accessing the website through a proxy that needs logon, pass in the proxy_username, proxy_password to the constructor. Sometimes, the…
-
The Power of C++ in Hands of a Junior Developer
This 17 seconds anime shows the unbridled power of C++ in the hands of a junior developer. As C++ creator, Bjarne Stroustrup, once said: C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
-
C/C++: Allocate Variable-size Arrays on the Stack
C language provides the alloca function to allocate arbitrary size array on the stack. After the function returns or the scope ends, the stack memory is automatically reclaimed back(popped back) without the developer having to deallocate it explicitly and thereafter is unsafe to access it again from another function. The below code shows allocating fixed…
-
C++ Empty Class and Function
More than 10 years ago, when I first debugged my Boost code, I stepped into empty class and empty function. At that time, I was wondering what empty class and function devoid of any code is good for. In this tip, I am going to use a simple endian swap example to demostrate the use…
-
C++23: Mutable string_view
In the upcoming C++23, the mutable string_view proposal is under review for inclusion in the next Standard Library. As we all know the current immutable string_view has two members, a const pointer to a constant char array and a constant length whereas in the mutable sibling, both members are modifiable. Let me illustrate with a…
-
Deleaker Review
What keeps a C++ developer awake at night? A nagging question at the back of his subconsciousness is “Does my application have a memory leak?”. Continual memory leaks can be detrimental to long-running programs and eventually, the system runs out of memory and is stopped in its operation. Detection and elimination of memory leak should…
-
Visual C++ 6.0 Developer’s Reference
Came across this picture of Visual C++ 6.0 Developer’s Reference(1998) posted by raddevus. I had a C++ Master Reference published in 1999. It has 1500 pages of C++ language and library reference! I had perhaps only read one page(about atoi()). It is like a predecessor of Cppreference except it is printed on book and is…
-
Running VC++ Executable on User Machine Without its DLLs
Since this question is asked on CodeProject today, I’ll answer it here. To deploy without having to install the Visual C++ DLLs, the program has to be linked statically. Linking to C runtime statically: Right-click on your project in the Solution Explorer and select Properties and go to C/C++ -> Code Generation. Select Multithreaded (/MT)…
-
Optimization Turns Out to Be Pessimization!
Benchmark is hosted at Github I have doing this optimization in my hobby OpenGL projects for years. My only sin is I did not measure their performance. I just assumed the one with less operation must be the faster one. Whenever a programmer wants to do get a fractional value of a maximum integer value,…
-
C++17: codecvt_utf8 is deprecated
Last week, I got this compilation error after upgrading my Visual C++ project to C++17 for using codecvt_utf8 to convert UTF-8 string back and fro wchar_t string. error C4996: ‘std::codecvt_utf8<wchar_t,1114111,0>’: warning STL4017: std::wbuffer_convert, std::wstring_convert, and the <codecvt> header (containing std::codecvt_mode, std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT deprecated.)…