E1134: invalid representation declaration

View source

meta repr(C) asserts that a struct has the layout of a C struct (ADR-0097).

meta repr(C) asserts that a struct has the layout of a C struct (ADR-0097). The compiler checks the assertion. A generic struct is rejected, because its layout depends on parameters. A struct with an erg, abs or ins field is rejected, because these fields carry ownership state, which C has no word for. The message names the declaration and the reason.

The same code is reported when a VolatileAddress[T] names a type that is not declared meta volatile. The message then names the target type and says that it must be declared meta volatile.

Example

actus
meta repr(C)
struct Header[N: Usize] {
    tag: u8,
}

verb main() {
}
actus
meta repr(C)
struct Header {
    erg tag: u8,
}

verb main() {
}
actus
import std::volatile;

meta repr(C)
struct Registers {
    status: u32,
}

verb read_status(abs address: VolatileAddress[Registers]) {
}

verb main() {
}

Fix

Declare a concrete struct with plain value fields. A volatile target also carries meta volatile.

actus
meta repr(C)
struct Header {
    tag: u8,
}

verb main() {
}
actus
import std::volatile;

meta repr(C)
meta volatile
struct Registers {
    status: u32,
}

verb read_status(abs address: VolatileAddress[Registers]) {
}

verb main() {
}

Run actus explain E1134 in your terminal to read this entry offline. Browse Modules & rules or all error codes.