04.11.2011, 04:57
Hi there!
I currently do some work with macros and got stuck at a very ugly point.
Now I got something like that. (The code is only an example)
The problem:
Now my Moo:moo4 is transformed to Moo_moo4 but it should be Moo_1 as moo4 is defined with 1!
Also somevar should be the definition of %0 (in that example moo4, so 1);
I get:
I need:
So I need to let the precompiler use the macroes for moo1-moo4 first to replace them with their definitions and let run my code afterwards so that every moo1 etc will become its definition (fckn hard to explain >.<)
How could I do that right? Or is it impossible?
Maybe our god ****** may help
I currently do some work with macros and got stuck at a very ugly point.
Now I got something like that. (The code is only an example)
pawn Код:
#define moo4 1
#define moo3 2
#define moo2 3
#define moo1 4
new bool:FALSE = false;
#define UseMoo(%0) do{ new tmpstring[20]; format(tmpstring, sizeof(tmpstring), "Moo_%d", %0); CallLocalFunction(tmpstring, "d", para1); }while(FALSE)
#define MOO:%0{%1} forward Moo_%0(para1); public Moo_%0(para1) { new somevar = %0; %1 }
public OnCallMoo(id, para1)
{
UseMoo(id);
}
Moo:moo4
{
// some code
}
Now my Moo:moo4 is transformed to Moo_moo4 but it should be Moo_1 as moo4 is defined with 1!
Also somevar should be the definition of %0 (in that example moo4, so 1);
I get:
pawn Код:
forward Moo_moo4(para1);
public Moo_moo4(para1)
{
somevar = %0; // error, unknown symbol "" as %0 should be the definition of moo4 but is nothing somehow
// code ...
}
pawn Код:
forward Moo_1(para1);
public Moo_1(para1)
{
somevar = 1;
// code ...
}
How could I do that right? Or is it impossible?
Maybe our god ****** may help