Posts Tagged preprocessor

C++ For C# Developers: Part 35 – Modules, The New Build Model

Tags: , , , ,

We’ve already seen C++’s traditional build model based on #include. Today we’ll look at the all-new build model introduced in C++20. This is built on “modules” and is much more analogous to the C# build model. Read on to learn how to use it by itself and in combination with #include!

Read the rest of this article »

2 Comments

C++ For C# Developers: Part 24 – Preprocessor

Tags: , ,

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.

Read the rest of this article »

4 Comments

C++ For C# Developers: Part 5 – Build Model

Tags: , , ,

Today’s article continues the series by introducing C++’s build model, which is very different from C#. We’ll go into preprocessing, compiling, linking, header files, the one definition rule, and many other aspects of how our source code gets built into an executable.

Read the rest of this article »

10 Comments

IL2CPP Output for C# 7.3: Everything Else

Tags: , , , , ,

Today we conclude the series by looking at all the remaining features in C# 7.3 that we get access to in Unity 2018.3. Read on to learn about new kinds of structs, in parameters, new where constraints, discards, default literals, generalized async returns, and new preprocessor symbols!

Read the rest of this article »

3 Comments

C++ Scripting: Part 8 – Platform-Dependent Compilation

Tags: , , , ,

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.

Read the rest of this article »

No Comments

How to Detect If the Unity Engine Is Available

Tags: ,

Sometimes we write code that’s meant to be run outside of the Unity engine. This could be anything from unit tests being run in MonoDevelop or Visual Studio to shared code that’s used on a multiplayer server. Regardless, the Unity engine isn’t available for use unless you’re running in the editor or a deployed build. This means you’ll have problems whenever you access the Unity engine via Debug.Log, GameObject, or MonoBehaviour. Today’s article shares some quick tips that enable you to tweak your code so that you can detect whether the Unity engine is available for use. Read on to learn how!

Read the rest of this article »

3 Comments

Easily “Compile Out” Function Calls

Tags: , ,

Taking another break from the iterator series, this week we’ll take a look at an exciting .NET feature that can easily and cleanly remove the calls to a function throughout the whole code base. Unity uses this for Debug.Assert and you can use it for all sorts of functions, too. Wouldn’t it be nice if we could strip out all the debug functions from the production build of our game but leave them in during development? Read on to learn how!

Read the rest of this article »

4 Comments

From AS3 to C#, Part 20: Preprocessor Directives

Tags: ,

Today’s article continues the series by looking at C#’s preprocessor support, which is like an expanded version of AS3’s compile-time constants and conditional compilation. Read on to learn about all the strange (and powerful) #something lines you can put in your code.

Read the rest of this article »

2 Comments