QuakeC: Variadic macros? - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10) +--- Forum: Xonotic - Development (https://forums.xonotic.org/forumdisplay.php?fid=12) +--- Thread: QuakeC: Variadic macros? (/showthread.php?tid=4807) |
QuakeC: Variadic macros? - WannabeUser - 03-10-2014 So i couldnt help it and started playing with QuakeC a bit. Not to bad but now i am kinda stuck. Is there a way to define a variadic macro (function is hopeless i guess)? Reason i am asking is: I want to hook sprint which sadly is sometimes given multiple string parameters and id rather not resort to sed/replace-in-files just for testing. I am using fteqcc (would be using gmqcc but it threw errors at me trying to compile the codebase i am playing around with and i didnt feel like investigating) which seems to hapilly accept ... in macro definitions but then has no clue what __VA_ARGS__ is (it doesnt expand ... either which gave me slight hope i am just doing it wrong). Any clues? RE: QuakeC: Variadic macros? - Mario - 03-10-2014 I have no problems with GMQCC, running Xonotic Git. Without it, you won't be able to get variadic arguments. The Git repository should give you a working codebase & compiler: http://dev.xonotic.org/projects/3/wiki/Repository_Access If you can get that working, there's an example of variadic arguments in the gamecode already, using sprintf: #define printf(...) print(sprintf(__VA_ARGS__)) RE: QuakeC: Variadic macros? - WannabeUser - 03-10-2014 Wow, very nice. Thanks alot. I didnt have to much hope this was going to work at all. I guess gmqcc here i come then! |