Sunday, 19 February 2017

Windows Magazines

Visual Studio Magazine is usually the best for previewing upcoming changes in Visual Studio.

MCPmag is also a great resource for Microsoft Certified Professionals.

Sunday, 12 February 2017

The NUL terminated string in C - An Ode to the PDP-11

In C, strings are null (or NUL) terminated ("backslash 0").  The PDP-11 assembly language supported NUL terminated strings, as did Martin Richards' BCPL, the precursor of C. Dennis Ritchie found the use of a NUL terminator more convenient than having to store the length of a string. It also makes for some elegant pointer based code!

MBCS and other Compiler Flags in Visual C/C++

When writing C and C++ code in Visual Studio understanding your compiler flags is critical.

These are configured under -

Project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor.

One of the default ones you might come across is _MBCS, which stands for multi-byte character set (an alternative to _UNICODE).  These directives define what the compiler understands a "character" to be. ASCII and ANSI are not multi-byte character encodings.

A useful directive if you want to use the "traditional" C functions like fopen etc.which are deprecated in recent Visual Studio releases is _CRT_SECURE_NO_WARNINGS. (CRT is shorthand for C runtime).

More detail on why functions like fopen are deprecated can be found in this article on Security Features in the CRT.