Types and VariablesΒΆ

var = CVariable(
        c_type=Cint8,
        name="i8Mycustomint",
        initial_value=CLiteral(4),
        doc=Doc("My Custom Int8")
)
print(var.declare().render())
/** @brief My Custom Int8 */
int8_t i8Mycustomint = 4;
array = CArray(
    c_type=Cint8,
    name="i8Asdf",
    length=10,
    doc=Doc("My Custom Int8 Array", "This array is awesome because it can hold 10 int8")
)

print(array.declare().render())
/**
 * @brief My Custom Int8 Array
 * 
 * This array is awesome because it can hold 10 int8
 */
int8_t i8Asdf[10];
# New type
custom = Cint8.type('TMyCustomType')
var = CVariable(
    c_type=custom,
    name="tMyVar"
)
print(custom.typedef(doc=Doc("My Custom Type", "Awesome type because I have defined it")).render())
print(var.declare().render())
/**
 * @brief My Custom Type
 * 
 * Awesome type because I have defined it
 */
typedef int8_t TMyCustomType;
TMyCustomType tMyVar;
# Static
var = CVariable(c_type=Cuint8, name="u8Var", static=True)
print(var.declare().render())
static uint8_t u8Var;
# Static and const
var = CVariable(c_type=Cuint8, name="u8Var", static=True, const=True)
print(var.declare().render())
static const uint8_t u8Var;
# Constexpr
var = CVariable(c_type=Cuint8, name="u8Var", constexpr=True)
print(var.declare().render())
constexpr uint8_t u8Var;