Skip to content
Myr

Cast function pointers without prototype before calling them (#2842)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

clang complained that this is deprecated in all versions of standard C, and unsupported in C2x.

authored by Emanuele Torre · committed by GitHub · parent 3fa10e8 · Browse files · 1 file+5 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−5 removed

  • other:+5 added−5 removed

1 file+5 added−5 removed

modified:src/execute.c+5 added-5 removed
919 unmodified lines
920 in[i] = stack_pop(jq);921 }922 struct cfunction* function = &frame_current(jq)->bc->globals->cfunctions[*pc++];923 switch (function->nargs) {924 case 1: top = function->fptr(jq, in[0]); break;925 case 2: top = function->fptr(jq, in[0], in[1]); break;926 case 3: top = function->fptr(jq, in[0], in[1], in[2]); break;927 case 4: top = function->fptr(jq, in[0], in[1], in[2], in[3]); break;928 case 5: top = function->fptr(jq, in[0], in[1], in[2], in[3], in[4]); break;924 case 1: top = ((jv (*)(jq_state *, jv))function->fptr)(jq, in[0]); break;925 case 2: top = ((jv (*)(jq_state *, jv, jv))function->fptr)(jq, in[0], in[1]); break;926 case 3: top = ((jv (*)(jq_state *, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2]); break;927 case 4: top = ((jv (*)(jq_state *, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3]); break;928 case 5: top = ((jv (*)(jq_state *, jv, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3], in[4]); break;929 // FIXME: a) up to 7 arguments (input + 6), b) should assert930 // because the compiler should not generate this error.931 default: return jv_invalid_with_msg(jv_string("Function takes too many arguments"));932 }
420 unmodified lines