Struct timespec with cbindgen

I have a struct that includes a ::libc::timespec field.

#[repr(C)]
pub struct Stat {
    last_used: libc::timespec,
    size: u64,
}

When I run cbindgen with

% cat cbindgen.toml
sys_includes = ["sys/stat.h"]
style = "tag"
language = "C"

I get

WARN: Can't find timespec. This usually means that this type was incompatible or not found.

And the output is

struct Stat {
  timespec last_used;
  uint64_t size;
};

The C compiler complains with

cgo:
clang errors for preamble:
In file included from ../../../../possum/go/cpossum/possum.go:5:
./../../possum.h:12:3: error: must use 'struct' tag to refer to type 'timespec'
timespec last_used;
^
struct
1 error generated.

I can see that I just need struct timespec instead of timespec, but how do I get this output in possum.h?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.