Using Preprocessor Symbols

Using Preprocessor Symbols



Warning: Solved, possibly duplicate post. Will take down on request.



Question: How do I set a variable like XBOX, XNA or MONOGAME true or false?

Elaboration: So there is this neat thing in c# that is the '#' (edit: preprocessor directives).

Used by me to divide my code up into regions:


#region SomeRegion
void Function() lalalala
#endregion



And by code I've seen to check platforms or lower level stuff:


#if MONOGAME
do moar stuf;
#endif

#if EDITOR (unity)
some editor specific stuf
#else
runtime specific stuff
#endif



But I want to know if I could do something like:


#MONOGAME = true



(I have tried that)



Background: I'm trying to import farseer into a monogame project. the #if !MONOGAME statement is not triggering false, and so it defines Vector2 along with xna's vector2, and so i want to manually set MONOGAME to 'true'.


#if !MONOGAME






These are called preprocessor directives, and are exactly what they sound like. They adjust the code before the code is compiled, so the code may not make it into compiled assembly. You can't set those from code.

– Ron Beyer
Sep 8 '18 at 13:49





1 Answer
1



Thanks @RonBeyer for pointing me in the right direction.



After a bit of research I found what I needed, a global preprocessor symbol.
This will trigger #if xyz queries true.


#if xyz



You can create a global one in project properties -> build -> general -> conditional compilation symbols.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)