[Question]Define in define -
Scottas - 30.06.2011
There are any way to use defines in define? For example:
pawn Код:
#define one #if !defined two #error...
So in that way, I could check entered parameters doesn't dublicated for some setup functions during compile time. Or there are any other way to do this?
Re: [Question]Define in define -
Shadoww5 - 01.07.2011
Could you explain again ?
Re: [Question]Define in define -
Lilcuete - 01.07.2011
I think he's trying to say that if he can put 2 defines in 1 but i think thats not possible.
Re: [Question]Define in define -
[LoD]Hauke - 01.07.2011
Maybe you mean
pawn Код:
#if defined one && !defined two
#define xyz
#endif
or
pawn Код:
#if defined two
#define one
#endif
Re: [Question]Define in define -
Shadoww5 - 01.07.2011
From what I understood it would be like this:
PHP код:
#if defined one
#define two
#else
#define one
#endif
Re: [Question]Define in define -
BigETI - 01.07.2011
Quote:
Originally Posted by Scottas
There are any way to use defines in define? For example:
pawn Код:
#define one #if !defined two #error...
So in that way, I could check entered parameters doesn't dublicated for some setup functions during compile time. Or there are any other way to do this?
|
Yes it is
Examples:
pawn Код:
#define RED 0xFF0000FF
#define invalidid SendClientMessage(playerid, RED, "This Player ID is not connected.");
pawn Код:
#define SetVehicleNumberPlateF(%0,%1,%2); UseBrackets\
{\
new formatstring[32];\
format(formatstring,sizeof(formatstring),%1,%2);\
SetVehicleNumberPlate(%0,formatstring);\
}
#define UseBrackets if(negative != positive)
new bool:negative = false, bool:positive = true;
As you can see that I've used defines inside the defines.
But if you write the same define text into it's own define so the compiler will crash.
Example:
pawn Код:
#define fail_defined_variable fail_defined_variable //It loops around and there is no end
new fail_defined_variable;
In the worst case after compiling it you have to close pawncc.exe from taskmanager.
Re: [Question]Define in define -
Scottas - 01.07.2011
Well, I'll give a better example
:
pawn Код:
// Some kind of function:
#define AddSymbol(%0)
// Then use this function
AddSymbol(SYMBOL_ONE);
AddSymbol(SYMBOL_TWO);
AddSymbol(SYMBOL_THREE);
What I am trying to do, is to make that compiler would give an error, if you enter the same symbol twice, like:
pawn Код:
// Then use this function
AddSymbol(SYMBOL_ONE);
AddSymbol(SYMBOL_TWO);
AddSymbol(SYMBOL_THREE);
AddSymbol(SYMBOL_TWO);
In this case, function AddSymboll should contain something like:
pawn Код:
#define AddSymbol(%0) #if defined SYMBOL_%0 #error Symbol already exists #endif
But function like that wont compile, it gives error. So all I want to know, is it possible to make something like that?
AW: Re: [Question]Define in define -
Nero_3D - 01.07.2011
Just use a stock
pawn Код:
#define AddSymbol(%0) stock %0
AddSymbol(SYMBOL_ONE);
AddSymbol(SYMBOL_TWO);
AddSymbol(SYMBOL_THREE);
AddSymbol(SYMBOL_TWO);
Re: [Question]Define in define -
Scottas - 02.07.2011
I am trying to add a field into sqlite database, and instead of getting table info and checking if field already exists, I want make something what I've tried to explane.
Nero, thanks. I haven't thought about this.