This macro definition crashes the compiler with no outcome.
#1

PHP Code:
#define SendClientMessage(%0,%1) SendClientMessage(%0, 0xD4D9ECFF, %1) 
that code, why?

urghhh



PHP Code:
public OnPlayerConnectEx(playerid) {
    for(new 
021i++)
        
SendClientMessage(playerid""); 
Reply
#2

#undef SendClientMessage?
Reply
#3

Quote:
Originally Posted by Thomas Dallos
View Post
#undef SendClientMessage?
Look at my code again, rethink WHY I DON'T HAVE A %2, BUT ONLY %0 AND %1

and rethink of what a macro definition is versus a native.

k thx
Reply
#4

Quote:
Originally Posted by Meller
View Post
Look at my code again, rethink WHY I DON'T HAVE A %2, BUT ONLY %0 AND %1

and rethink of what a macro definition is versus a native.

k thx
He is kind of right, you cannot re-define a symbol even with changed amount of parameters.

Well, you can define it but once you use it the compiler will crash.

It results in an infinite loop, SendClientMessage gets replaced with the new SendClientMessage, which again gets replaced by SendClientMessage (etc).
Reply
#5

Quote:
Originally Posted by NaS
View Post
He is kind of right, you cannot re-define a symbol even with changed amount of parameters.

Well, you can define it but once you use it the compiler will crash.

It results in an infinite loop, SendClientMessage gets replaced with the new SendClientMessage, which again gets replaced by SendClientMessage (etc).
I've done this with other natives earlier (several months ago), I used Kick(%0,%1) to return a SetTimerEx with an interval of the players ping for example. I've done this before, however this time something went wrong.
Reply
#6

But there's a difference between defining a macro with different arguments that calls a seperate function and a macro that would call itself.

OK:

#define Kick(%1,%2) DelayedKick(%1,%2)

Not OK:

#define Kick(%1,%2) Kick(%1)
#define printf(%1,%2) printf("%s%d",%1,%2)

Make a seperate function for SendClientMessage that has 2 arguments and then use that in the macro.

Code:
SendClientMessage2(playerid, text[]) SendClientMessage(playerid, 0xFFFFFFFFF, text);
#define SendClientMessage(%1,%2) SendClientMessage2(%1,%2)
Reply
#7

Quote:
Originally Posted by NaS
View Post
But there's a difference between defining a macro with different arguments that calls a seperate function and a macro that would call itself.

OK:

#define Kick(%1,%2) DelayedKick(%1,%2)

Not OK:

#define Kick(%1,%2) Kick(%1)
So why is these
#define Kick(%1,%2) Kick(%1)
being completely ignored then?

like it's only logical that if it's ended, it's ended. and that I'm only defining for i.ex.
Kick(%1,%2)
to be
Kick(%1)
Reply
#8

Quote:
Originally Posted by Meller
View Post
I've done this with other natives earlier (several months ago), I used Kick(%0,%1) to return a SetTimerEx with an interval of the players ping for example. I've done this before, however this time something went wrong.
Dude. "re-think"

NaS workaround should work for you.
Code:
SendClientMessage2(playerid, text[]) SendClientMessage(playerid, 0xFFFFFFFFF, text);
#define SendClientMessage(%1,%2) SendClientMessage2(%1,%2)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)