#define #else #if !defined Question
#1

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;
}
Reply
#2

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
Reply
#3

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...
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)