Posts Tagged il2cpp

Getting the Size of a Struct at Compile Time

Tags: , , , , ,

I continue to learn a lot by reading the C++ code that IL2CPP outputs. Like reading decompiled code, it gives some insight into what what Unity’s build process is doing with the C# we give it. This week I learned that sizeof(MyStruct) isn’t a compile-time constant like it is in C++. Because of that, IL2CPP generates some less-than-ideal C++ code every time you use it. Today’s article shows the process I went through to work around that issue and ends up with some code you can drop into your project to avoid the problem.

Read the rest of this article »

No Comments

Three Surprises I Encountered While Reading IL2CPP Output

Tags: , , ,

We code in C#, but that’s just a starting point. Our C# code is compiled to DLLs and then converted into C++ where it’s compiled again to machine code. The good news is that this isn’t a black box! I’ve recently been reading through the C++ code that IL2CPP outputs and learning quite a lot. Today’s article is about some of the surprises that I encountered and how you can change your C# code to avoid some nasty pitfalls.

Read the rest of this article »


The Magic of LINQ Expressions

Tags: , , ,

LINQ expressions aren’t the same thing as LINQ queries. They’re more like reflection for the syntax of C# itself. It’s a fascinating—and powerful—area of the language and I’ll be exploring it a little in today’s article.

Read the rest of this article »


IL2CPP Slowdown (Partially Solved)

Tags: , ,

The new IL2CPP scripting backend in Unity 4.6.2 and 5.0 is supposed to be much faster than the old Mono backend. I ran some benchmarks, but mostly found slowdowns compared to Mono. Today’s article shows the tests I ran, the results I got, and wonders why the IL2CPP version seems so slow. Perhaps one of you, dear readers, knows the reason why. Update: Part of the reason why has been discovered. Read on for updated results.

Read the rest of this article »