11.11.2010, 15:30
A macro replaces code by something "easier".
For example, if you take your macro:
Should you use it for example:
It would compile as:
Now obviously that'll cause the compiler to error.
So here's what the problem is: A macro replaces a piece of code. You must use a function to retrieve a variable.
For example, if you take your macro:
pawn Код:
#define GetName(%1) new name[MAX_PLAYER_NAME]; GetPlayerName(%1, name, MAX_PLAYER_NAME); return name
pawn Код:
format(string, sizeof string, "Hey %s", GetName(playerid));
pawn Код:
format(string, sizeof string, "Hey %s", new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); return name);
So here's what the problem is: A macro replaces a piece of code. You must use a function to retrieve a variable.