Adding compilation symbol in Unity IL2Cpp build solution

i’m building a App for UWP, before when i use to build it using .net scripting backend i use to add my Conditional compilation symbol at project properties > Build > General > Conditional Compilation symbols.

But now i cant find any option to add it when i build my project using IL2Cpp scripting bakend.
Though i tried to add it here


But it didn’t work for me , the code comes under defined symbol is not compiling.

For C++ projects in Visual Studio, the “Preprocessor Definitions” setting is the proper place for your defines. From this information it isn’t clear why it’s not working.

Only suggestion I can think of: are you using the correct C++ Preprocessor macros and/or syntax?

I assume you want some “debug only” code, but you shouldn’t need to manually define the macros as VS automatically defines them via compiler switches. See this SO post for more context: c++ - _DEBUG vs NDEBUG - Stack Overflow. Also keep in mind, C++ macros can be #undef’d if code; so make sure this isn’t happening.

For the IL2CPP project, you shouldn’t need to add any defines there. However, if you do want to manually change the generated code and add your of defines (not recommended), you’ll have to do this via the “Build Command Line”. Since IL2CPP is built by an external compiler, VS doesn’t provide a “real” Preprocessor Definitions option box because it doesn’t know how to pass these parameters. The option you see is only for adding defines for IntelliSense within the IDE, so you don’t get the red squiggly lines.

Can you show exactly what you add to “Preprocessor Definitions” and how you check for that define in code?

5248373--524222--upload_2019-12-5_12-56-12.png

In Script :
5248373--524228--upload_2019-12-5_13-0-52.png

Where is your script located? That code looks like C# rather than C++.

yes, its a c# script , for Hololens i’m building this using Il2Cpp scripting backend ,and the script is from my unity project .

Well adding a define there at that point is too late then. Your C# code was already compiled.

You want to add this define to player settings: Unity - Manual: Conditional compilation (see “Platform custom #defines” section).