Use value of constant as part of a macro
#5

I think I'm on the right way.

My macro:
Code:
#include <a_samp>

#define MYCONSTANT_A 1
#define MYCONSTANT_B 2
#define MYCONSTANT_C 3

#define MyTest:%0(%1) forward TestFunc_#%0(%1); public TestFunc_#%0(%1)

main(){}

public OnGameModeInit()
{
	AddPlayerClass(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	SetGameModeText("Test GM");
	new funcName[32];
	format(funcName, sizeof(funcName), "TestFunc_%d", MYCONSTANT_B);
	printf("Trying to call %s", funcName);
	CallLocalFunction(funcName, "dd", 123, 456);
	return true;
}


MyTest:MYCONSTANT_B(var1, var2)
{
	printf("Executed MYCONSTANT_B (%d, %d)", var1, var2);
}
Trying to compile that gives me two errors but if I run the pawn preprocessor using the -l command line option of the pawn compiler I find the following in the generated .list file:

Code:
forward TestFunc_#2(var1, var2); public TestFunc_#2(var1, var2)
{
	printf("Executed MYCONSTANT_B (%d, %d)", var1, var2);
}
So I just have to find a way to remove the #. If I remove it in the macro I get that:
Code:
forward TestFunc_MYCONSTANT_B(var1, var2); public TestFunc_MYCONSTANT_B(var1, var2)
{
	printf("Executed MYCONSTANT_B (%d, %d)", var1, var2);
}
Reply


Messages In This Thread
Use value of constant as part of a macro - by Programie - 11.04.2012, 16:57
Re: Use value of constant as part of a macro - by Jonny5 - 11.04.2012, 17:08
Re: Use value of constant as part of a macro - by Programie - 11.04.2012, 17:12
Re: Use value of constant as part of a macro - by Jonny5 - 11.04.2012, 17:19
Re: Use value of constant as part of a macro - by Programie - 11.04.2012, 17:31
Re: Use value of constant as part of a macro - by Jonny5 - 11.04.2012, 17:50
Re: Use value of constant as part of a macro - by Programie - 11.04.2012, 17:53
Re: Use value of constant as part of a macro - by Jonny5 - 11.04.2012, 17:57
Re: Use value of constant as part of a macro - by Programie - 11.04.2012, 18:09

Forum Jump:


Users browsing this thread: 3 Guest(s)