Tag mismatch
#1

This is not an easy question. I need someone with deep compiler knowledge, to explain to me what is happening under the hood.

Working:

pawn Код:
#include <a_samp>

enum E_TEST {
    E_WTF[32]
}

main () {
    new name[] = "Just a name";
    new test[E_TEST];
    strcat((test[E_WTF][0] = '\0', test[E_WTF]), name);
}
Failing

pawn Код:
strcat(((test[E_WTF])[0] = '\0', test[E_WTF]), name); // Warning: tag mismatch
I'm using some really contrived macros and I need the version in brackets to work. I just don't understand why it's not an compiler error, and just a tag mismatch error. Adding tags does not change anything, that's why I'm asking compiler magicians to explain to me the process which is happening here. Thank you
Reply
#2

Shorter example:
pawn Код:
(test[E_WTF])[0] = EOS;
Reply
#3

No clue as to what outcome you expected, nor if you expected it to work. But it would only be logical if you wrapped the whole thing, although I don't know why you would want to do that in this case.
Reply
#4

I've compiled it right now, nothing happened:
Reply
#5

You must compile:
PHP код:
strcat(((test[E_WTF])[0] = '\0'test[E_WTF]), name); // Warning: tag mismatch 
Or:
PHP код:
(test[E_WTF])[0] = EOS
Reply
#6

Quote:
Originally Posted by Paulice
Посмотреть сообщение
You must compile:
PHP код:
strcat(((test[E_WTF])[0] = '\0'test[E_WTF]), name); // Warning: tag mismatch 
Or:
PHP код:
(test[E_WTF])[0] = EOS
eheheh sorry I wasn't paying attention yesterday :c
By the way, you may probably already know it, but
Код:
        strcat(((test[E_WTF][0]) = '\0', test[E_WTF]), name);
        (test[E_WTF][0]) = EOS;
doesn't show up the tag mismatch warning. Doing this
Код:
(test[E_WTF][0])[1] = EOS;
gives the tag mismatch warning aswell. But if we do
Код:
new playerid[1];
(playerid)[0] = 1;
Compiler won't complain. Maybe the warning shows up because the E_WTF belongs to an enum? Indeed,
Код:
new playerid[E_TEST];
(playerid)[0] = 1;
shows up the warning.
Reply
#7

the bracket around the word? I mean have you tried (playerid[0])?
Reply
#8

Alright, as VVwVV pointed out
pawn Код:
(test[E_WTF])[E_TEST:0] = EOS;
works. What I don't understand is why
pawn Код:
(_:test[E_WTF])[0] = EOS;
does not work

https://github.com/Zeex/pawn/issues/182
For now I compiled the compiler with the warning turned off, as the code works except for all the tag mismatch warnings
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)