Posts Tagged string

C++ For C# Developers: Part 50 – I/O Library

Tags: , , ,

We’ve seen a bit of I/O in the C Standard Library already, but this isn’t C++’s main way to perform I/O. Today we’ll look at the “streams” API that’s designed around C++’s support for strong types and overloaded operators rather than facilities like “format strings.” We’ll also see how to write the canonical “Hello, world!” program in C++ and how to finally implement DebugLog!

Read the rest of this article »

No Comments

C++ For C# Developers: Part 44 – Strings Library

Tags: , ,

C++ string literals may be simple arrays of characters, but the Standard Library provides a lot of support on top of that. From a string class to regular expressions, we have a full set of tools to deal with strings in a wide variety of ways.

Read the rest of this article »

No Comments

C++ For C# Developers: Part 38 – C Standard Library

Tags: , , , ,

Today we’ll begin exploring the C++ Standard Library. As C++ is mostly a superset of C, the C++ Standard Library is mostly a superset of the C Standard Library. So we’ll begin there!

Read the rest of this article »

No Comments

C++ For C# Developers: Part 7 – Pointers, Arrays, and Strings

Tags: , , ,

Today we’ll continue the series with a look into pointers and, very differently from C#, the related concepts of arrays and strings. We’ll cover some interesting C++-only features, such as function pointers along the way.

Read the rest of this article »

6 Comments

Simple Formula Evaluator Revisited

Tags: , , , , , ,

A couple years ago, I wrote an article showing how to empower game designers with the ability to write simple formulas like PlayerLevel*100+100. These are much more useful than just constants and don’t require any of the complexity of a real programming language. Today we’ll bring it into the Burst-compatible world and also improve its ability to handle more complex formulas.

Read the rest of this article »

5 Comments

Throwing Exceptions in Burst-Compiled Jobs

Tags: , ,

Unity’s Burst compiler imposes an interesting subset of C#. The “no managed objects” rule of thumb is not always correct. Today we’ll look at eExceptions, which are managed objects but are partially supported by Burst. What’s allowed and what’s banned? Read on to find out.

Read the rest of this article »

1 Comment

Common Functions That IL2CPP Slows Down

Tags: , , ,

IL2CPP can really slow our code down sometimes, and not just for esoteric features. Calling common math and string functions can be dramatically slower in IL2CPP. Today’s article shows you how you can work around this to speed them back up.

Read the rest of this article »

2 Comments

Three More IL2CPP Surprises

Tags: , , ,

The story usually has three parts. First, find the highest CPU cost functions in a profiler. Second, look at the corresponding C++ code that IL2CPP generated from C#. Third, stop using more parts of C#. Today’s article explores some more IL2CPP output and discovers some more areas of C# that are shockingly expensive to use.

Read the rest of this article »

No Comments

C++ Scripting: Part 24 – Default Parameters

Tags: , , , , ,

We’ve been able to call methods since the very beginning, but we’ve always had to pass all the parameters. Today we’ll add support for default parameters so you can skip them sometimes. There’s a surprising amount of detail involved with this, so read on to learn some caveats of C#, .NET, and C++.

Read the rest of this article »

No Comments

Garbage Gotchas

Tags: , , , , , , ,

Sometimes it seems like Unity programming is a minefield. Plenty of innocuous-looking code secretly creates garbage and eventually the GC runs and causes a frame hitch. Today’s article is about some of those less-obvious ways to create garbage.

Read the rest of this article »

2 Comments