#define #else #if !defined Question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: #define #else #if !defined Question (
/showthread.php?tid=599439)
#define #else #if !defined Question -
SkyFlare - 26.01.2016
Hey everyone, just a general query, wondering if this would work and if it wouldn't... what have I done wrong?
Code:
CMD:something(playerid, params[])
{
#if defined SOMETHING
#undef SOMETHING
#endif
#else
#if !defined SOMETHING
#define SOMETHING
#endif
return 1;
}
Re: #define #else #if !defined Question -
[eLg]elite - 26.01.2016
These are called directives and they tell the computer what to do upon compile and not after that. You could use it if you didn't want a certain system to load while you are working on a new one, but I think most people would prefer to use /* */. They aren't useful for much other then checking if it is a gamemode or a filterscript. I learned this information from -Carrot and Vince.
https://sampforum.blast.hk/showthread.php?tid=598432
Re: #define #else #if !defined Question -
Crayder - 26.01.2016
pawn Code:
#if defined SOMETHING
#undef SOMETHING
#else
#define SOMETHING
#endif
In that command, no it will not work. But if something similar to this was used in includes and stuff it would.
It is all PRE PROCESSED. So it only works while compiling. Not while running.
Basically...
Re: #define #else #if !defined Question -
SkyFlare - 26.01.2016
oh PRE PROCESSED, thanks Crayder, that's a shame, was trying to cut down some compile times haha
looks like i gotta hard code the if statements with variables etc