Macros help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Macros help (
/showthread.php?tid=658156)
Macros help -
bgedition - 25.08.2018
Hello guys,
Is there any way to get the optional parameters from a macro like in C++, with __VA_ARGS__?
To have this:
Код:
#define Func1(...) \
Func2(<Some constant like in C++ __VA_ARGS__ here>, 0)
Example:
Код:
ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_LIST, Func1("HEADER"), Func1("WELCOME_MSG", GetName(playerid)), Func1("Go"), Func1("Quit"));
The intention here is that when the macro is called the 'Func2' will always have at least 2 arguments. Is there any way to do this in pawn?
Thanks,
Michael
Re: Macros help -
bgedition - 25.08.2018
Quote:
Originally Posted by ******
|
Thank you. This helps but I am getting run time error. Since I am trying this with a function from your library. How can I add a default for va_args and va_format when none are specified.
Re: Macros help -
bgedition - 25.08.2018
Sorry, let me clarify. When nothing is specified for 'va_args<>', the server gets run time error 5 which is invalid memory access. How can I prevent this from happening. This is the reason to try with macros but it does not work as expected.
Re: Macros help -
bgedition - 25.08.2018
YSI v4