C++ programmer, *nix enthusiast, Unreal Engine 4 game developer, and a lifelong learner.

I am a daydreamer for life (a.k.a. INFP); that’s why I craft videogames!

Write Your Own Cross-Platform Cryptographic Library

Previously I’ve described the process of building Crypto++ on both FreeBSD and Windows using the GCC, MinGW and VC++ compilers.

Now, we want to develop our own cross-platform cryptographic wrapper library around Crypto++. I’ve already uploaded the full source code to GitHub. You can find the link to the code on GitHub at the end of this article.

Before you proceed, you have to build the Crypto++ library as I mentioned earlier here.

[ Read More... ]

How to Build C++ Cryptographic Library, Crypto++

Crypto++ is an awesome free and open source C++ class library of cryptographic algorithms and schemes which fully supports 32-bit and 64-bit architectures for many major operating systems, including FreeBSD, Linux, Solaris, Windows, Mac OS X and iOS. Currently, Crypto++ officially supports the following compilers:

  • MSVC 6.0 - 2010
  • GCC 3.3 - 4.5
  • C++Builder 2010
  • Intel C++ Compiler 9 - 11.1
  • Sun Studio 12u1, Express 1108, Express 06/10

The latest version at the time of this writing is 5.6.1.

In spite of the power that Crypto++ offers, building and using it can be a little bit tricky. In the following we will describe the process of building Crypto++ on both FreeBSD and Windows using the GCC, MinGW and VC++ compilers.

[ Read More... ]

Should I Check if a Pointer Is NULL Before Deleting It?

Most of the time I see some C++ programmers who check if a pointer is NULL before deleting it.

if (ptr != NULL) {
    delete ptr;
    ptr = NULL;

Well, according to C++03 [ISO/IEC IS 14882:2003] §5.3.52 which explicitly states:

…if the value of the operand of delete is the null pointer the operation has no effect.

Therefore, deleting a NULL pointer has no effect (if the deallocation function is one supplied in the standard library), so it is not necessary to check for a NULL pointer before calling delete.

delete ptr;
ptr = NULL;
  • _Note: Keep in mind that deleting a void* pointer results in undefined behavior whether it’s NULL or not._

Get nFringe to Work with Visual Studio 2012

As you’ve noticed there’s still no official support for Microsoft Visual Studio 2012 in recent Pixel Mine nFringe releases. While ago I came across an awesome forum post at Epic Games Forums which describs a simple process of getting nFringe to work with VS2012. Since then I’ve used it in my day to day development tasks and I had no difficulties at all using it. And damn, it’s pretty stable despite the fact that not officially supported by Pixel Mine. Even nFringe version 1.1 which I’ve tested is playing nice with VS2012.

The only prerequisite that you need is your previous VS2010 + nFringe installation to obtain some files from it. Once you’ve acquired these files you don’t need VS2010 or nFringe installer for further installations.

1. Open Windows Command Prompt (cmd.exe) and run the following commands:

> xcopy /E "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Pixel Mine" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\"
> xcopy /E "C:\Program Files (x86)\Microsoft Visual Studio 10.0\UnrealScript" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\"

2. Open up extension.vsixmanifest in Notepad or your favorite editor and change VisualStudio Version to 11 (Note: In the following path change 1.1 with your nfringe version, e.g. 1.2).

> notepad "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Pixel Mine nFringe (UnrealScript)\1.1\extension.vsixmanifest"

      <VisualStudio Version="11.0">

3. Run the following command to register nFringe extension in Visual Studio 2012:

> "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /setup

4. Finally, you need to re-validate your nFringe license in VS2012.

Happy coding ;)

Windows 8, Install .NET Framework 2.0 - 3.5 Offline

Well, I’ve failed to install .NET Framework 2.0/3.5 in Windows 8 using Program and Features in Control Panel, which I need for an older project I’ve done long ago. But I came across an easy solution which did the trick.

In Windows Command Prompt (cmd.exe) or Run dialog, enter the following command and hit Enter:

> Dism /online /enable-feature /featurename:NetFx3 /All /Source:x:\sources\sxs /LimitAccess

Replace x: with path of your Windows 8 installation DVD.

  • Note: You have to run cmd.exe as Administrator in order for this to work!