Skip to content

Commit

Permalink
Visual Studio 22 does not compile va_arg that are function pointers. …
Browse files Browse the repository at this point in the history
…Instead, the function pointers must be a typdef. For what its worth, see https://stackoverflow.com/a/37114318.
  • Loading branch information
cfis committed Apr 20, 2023
1 parent 4de2bc1 commit 75ff5dd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/ffi/fixtures/ClosureTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@

double testClosureVrDva(double d, ...) {
va_list args;
double (*closure)(void);
typedef double (*closure_fun)(void);

va_start(args, d);
closure = va_arg(args, double (*)(void));
closure_fun closure = va_arg(args, closure_fun);
va_end(args);

return d + closure();
}

long testClosureVrILva(int i, long l, ...) {
va_list args;
int (*cl1)(int);
long (*cl2)(long);
typedef int (*cl1_fun)(int);
typedef long (*cl2_fun)(long);

va_start(args, l);
cl1 = va_arg(args, int (*)(int));
cl2 = va_arg(args, long (*)(long));
cl1_fun cl1 = va_arg(args, cl1_fun);
cl2_fun cl2 = va_arg(args, cl2_fun);
va_end(args);

return cl1(i) + cl2(l);
Expand Down

0 comments on commit 75ff5dd

Please sign in to comment.