C# and C++ have similar lists of preprocessor directives like #if
, but their features and usage are very different. This is especially the case in C++ with support for “macros” that can replace code. Today we’ll look into everything we can use the preprocessor for in C++ and compare with C#’s preprocessor.
Posts Tagged define
The series continues today to fill a small, but important gap in the C++ plugin’s build script. Unity helpfully provides symbols like UNITY_IOS
for us to check with #if
. This lets us add and remove blocks of code that should only be present in a certain build of the game. We’d like the same functionality in C++ that Unity provides to C#, so today we’ll upgrade the build script to allow that.
The assert
function is found in many languages to provide a way for you to check for errors only in debug builds of your code. For release/production builds, the asserts are removed to make the compiled code smaller and remove all of the overhead of the error checking. Flash doesn’t come with such a feature built-in, but can we build one ourselves? Today’s article will try to do just that using nothing but Adobe’s modern AS3 compiler: ASC 2.0.
Amazingly, I’ve never covered the const
keyword, but a couple of recent comments have prompted me to cover the subject in depth with today’s article.