Skip to content

Instantly share code, notes, and snippets.

Last active January 5, 2019 12:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
const std = @import("std");
const c = @cImport({
const MyInputType = struct {
value: u8
const MyResultType = struct {
input: type,
pub fn doSomethingWithInputType(comptime self: MyResultType) void {
std.debug.warn("{}\n", @memberName(self.input, 0));
pub fn main() void {
const a = getResultType(MyInputType);
const b = getResultType(struct { another_input_type: u8 });
fn getResultType(comptime input_type: type) MyResultType {
// As soon as I add the c call, I get 'unable to evaluate constant expression'.
// If you comment the line below this snippet should run properly.
return MyResultType {
.input = input_type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment