Skip to main content
The comptime_struct type and the @concat_structs builtin were removed in SDK 2.10.0. See Version 2.10.0. This guide explains how to migrate existing code to use named struct types instead.
For a full reference on struct types in CSL, see Types.

Replacing comptime_struct with struct

As a consequence of the removal of comptime_struct, @concat_structs can no longer be used. Before (removed):
After: CSL now requires struct types to be declared explicitly. These can be used at both compile time and runtime. The following code serves the equivalent function to the above example:

Partial Initialization

Another key difference between comptime_struct and struct is that all fields must be declared and set. No partial initialization can be done, sometimes requiring the use of temporary placeholders. Before (removed):
After:

Parameterized Structs

Sometimes, the members of a given struct need to vary based on compile-time parameters or constants. This can be achieved by writing a comptime function that returns a type. The returned type is a struct whose fields depend on the arguments passed to the function. For example, a function that returns a point type whose coordinate type depends on the scale type requested:
See also the parameterized struct types example in the Language Guide for additional patterns.