# Initializing arguments to @call during comptime

**URL:** <https://ziggit.dev/t/initializing-arguments-to-call-during-comptime/18058>\
**Category:** Help\
**Tags:** language, standard-library, zig-0-17\
**Created:** [October 22, 2026, 5:39pm UTC](https://ziggit.dev/t/initializing-arguments-to-call-during-comptime/18058 "2026-10-22T17:39:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kapusta](https://ziggit.dev/letter_avatar_proxy/v4/letter/k/4af34b/32.png) [@kapusta](https://ziggit.dev/u/kapusta)\
**Post date:** [October 22, 2026, 5:39pm UTC](https://ziggit.dev/t/initializing-arguments-to-call-during-comptime/18058/1 "2026-10-22T17:39:50Z")

</div>

HELLO,

I want to write down some comptime wrapper for zig functions to be converted into lua CFunctions, but Im stuck with constructing argument object for `@call`.

For now i try to do something like:

```zig
const info = @typeInfo(@TypeOf(function));
const infoFn = info.@"fn";
//...
                         // V- not sure about backing int for now, but thats not the problem
const Args = @Struct(.auto, u32, &.{}, infoFn.param_types, infoFn.param_attrs);
//...
const v = struct {
    fn wrapper(state: ?*lua.lua_State) callconv(.c) c_int {
        var args: Args = undefined;
        inline for (info.@"fn".param_types[1..]) |param_type| {
            // do something with args, or Args???
            //...
        }
        @call(.auto, function, args);
//...
        return 0;
    }
}
return v.wrapper;

```

but with that I dont even provide property names, and the param\_types is `[]?type`, where `@Struct` expects it to be `[]type`

So, how can I setup args to depend on anything?

Unless I should just use for my functions (that are to be wrapped) `fn (*lua_State, args: anytype) anytype` and then just loop over those (anytype) args which at least I can try to instanciate or append to.

---

<div class="post-metadata">

**Author:** ![Lygaen](https://ziggit.dev/user_avatar/ziggit.dev/lygaen/32/7197_2.png) [@Lygaen](https://ziggit.dev/u/Lygaen)\
**Post date:** [October 22, 2026, 6:26pm UTC](https://ziggit.dev/t/initializing-arguments-to-call-during-comptime/18058/2 "2026-10-22T18:26:11Z")

</div>

Did a similar implementation a few months ago, have a look at [https://codeberg.org/mathieu\_cayeux/lua.zig/src/branch/main/src/stack.zig](https://codeberg.org/mathieu_cayeux/lua.zig/src/branch/main/src/stack.zig)

It is not updated to the latest zig but the main idea will work nontheless

If you want to find it yourself, have a look around std.meta.ArgsTuple (and @call) and its usage in std
