mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 03:50:36 +00:00
Fix warning, and better tests for __VA_ARGS__
This commit is contained in:
parent
001d853f38
commit
6fc5b32123
3 changed files with 20 additions and 10 deletions
2
ftepp.c
2
ftepp.c
|
@ -720,7 +720,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param
|
|||
break;
|
||||
|
||||
case TOKEN_VA_ARGS_ARRAY:
|
||||
if (out->constval.i >= varargs) {
|
||||
if ((size_t)out->constval.i >= varargs) {
|
||||
ftepp_error(ftepp, "subscript of `[%u]` is out of bounds for `__VA_ARGS__`", out->constval.i);
|
||||
vec_free(old_string);
|
||||
return false;
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
void print(...) = #1;
|
||||
|
||||
#define NOPARENS(...) __VA_ARGS__
|
||||
#define callem(func, args) func NOPARENS(args)
|
||||
// method 0
|
||||
#define METHOD__(...) __VA_ARGS__
|
||||
#define METHOD_0(F,A) F METHOD__(A)
|
||||
|
||||
#define callen(func, ...) func __VA_ARGS__##[0]
|
||||
// method 1
|
||||
#define METHOD_1(F,A) F(METHOD__ A)
|
||||
|
||||
// method 2
|
||||
#define METHOD_2(F,...) F __VA_ARGS__##[0]
|
||||
|
||||
// method 3
|
||||
#define METHOD_3(F,...) F __VA_ARGS__
|
||||
|
||||
void main() {
|
||||
print(NOPARENS("hello ", "world\n"));
|
||||
callem(print, ("Yay", ", there\n"));
|
||||
callen(print, ("Woah",", there\n"));
|
||||
METHOD_0(print, ("Method", " <zero>\n"));
|
||||
METHOD_1(print, ("Method", " <one>\n"));
|
||||
METHOD_2(print, ("Method", " <two>\n"));
|
||||
METHOD_3(print, ("Method", " <three>\n"));
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ I: pp_va_args.qc
|
|||
D: __VA_ARGS__
|
||||
T: -execute
|
||||
C: -std=fteqcc
|
||||
M: hello world
|
||||
M: Yay, there
|
||||
M: Woah, there
|
||||
M: Method <zero>
|
||||
M: Method <one>
|
||||
M: Method <two>
|
||||
M: Method <three>
|
||||
|
|
Loading…
Reference in a new issue