Overwriting Defines
#1

I'm trying to make a simple include to help debug Text Draws, to show the variable name, but I'm getting redefinition errors.

Use example: TextDrawDestroy<"name">(td); should output "[DTD: DEBUG] [name] Destroy"
Use example: TextDrawDestroy(td); should output "[DTD: DEBUG] [Unknown] Destroy"

The blocks of defines at the bottom work, but the two define blocks conflict.

Code:
pawn Код:
stock _safe_TextDrawDestroy(_safeName[], Text:text) {
    printf("[DTD: DEBUG] [%s] Destroy", _safeName);
    TextDrawDestroy(text);
}
stock _safe_TextDrawShowForPlayer(_safeName[], playerid, Text:text) {
    printf("[DTD: DEBUG] [%s] ShowForPlayer(%i)", _safeName, playerid);
    TextDrawShowForPlayer(playerid, text);
}
stock _safe_TextDrawHideForPlayer(_safeName[], playerid, Text:text) {
    printf("[DTD: DEBUG] [%s] HideForPlayer(%i)", _safeName, playerid);
    TextDrawHideForPlayer(playerid, text);
}
stock _safe_TextDrawShowForAll(_safeName[], Text:text) {
    printF("[DTD: DEBUG] [%S] ShowForAll", _safeName);
    TextDrawShowForAll(text);
}
stock _safe_TextDrawHideForAll(_safeName[], Text:text) {
    printF("[DTD: DEBUG] [%S] HideForAll", _safeName);
    TextDrawHideForAll(text);
}
stock _safe_TextDrawSetString(_safeName[], Text:text, string[]) {
    printf("[DTD: DEBUG] [%s] SetString('%s')", _safeName, string);
    TextDrawSetString(text, string);
}

// Text Draw
#define TextDrawDestroy(%1);                _safe_TextDrawDestroy("Unknown",%1);
#define TextDrawShowForPlayer(%1,%2);       _safe_TextDrawShowForPlayer("Unknown",%1,%2);
#define TextDrawHideForPlayer(%1,%2);       _safe_TextDrawHideForPlayer("Unknown",%1,%2);
#define TextDrawShowForAll(%1);             _safe_TextDrawShowForAll("Unknown",%1);
#define TextDrawHideForAll(%1);             _safe_TextDrawHideForAll("Unknown",%1);
#define TextDrawSetString(%1,%2);           _safe_TextDrawSetString("Unknown",%1,%2);


#define TextDrawDestroy<%1>(%2);            _safe_TextDrawDestroy(%1, %2); //Line 39
#define TextDrawShowForPlayer<%1>(%2,%3);   _safe_TextDrawShowForPlayer(%1, %2, %3); //Line 40
#define TextDrawHideForPlayer<%1>(%2,%3);   _safe_TextDrawHideForPlayer(%1, %2, %3); //Line 41
#define TextDrawShowForAll<%1>(%2);         _safe_TextDrawShowForAll(%1, %2); //Line 42
#define TextDrawHideForAll<%1>(%2);         _safe_TextDrawHideForAll(%1, %2); //Line 43
#define TextDrawSetString<%1>(%2,%3);       _safe_TextDrawSetString(%1, %2, %3); //Line 44

And the errors:
pawn Код:
C:\...\debug_textdraw.inc(39) : warning 201: redefinition of constant/macro (symbol "TextDrawDestroy<%1>(%2);")
C:\...\debug_textdraw.inc(40) : warning 201: redefinition of constant/macro (symbol "TextDrawShowForPlayer<%1>(%2,%3);")
C:\...\debug_textdraw.inc(41) : warning 201: redefinition of constant/macro (symbol "TextDrawHideForPlayer<%1>(%2,%3);")
C:\...\debug_textdraw.inc(42) : warning 201: redefinition of constant/macro (symbol "TextDrawShowForAll<%1>(%2);")
C:\...\debug_textdraw.inc(43) : warning 201: redefinition of constant/macro (symbol "TextDrawHideForAll<%1>(%2);")
C:\...\debug_textdraw.inc(44) : warning 201: redefinition of constant/macro (symbol "TextDrawSetString<%1>(%2,%3);")
Of course, if anyone knows how to make TextDrawDestroy(td); output "[DTD: DEBUG] [td] Destroy" id prefer it


Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)