ZigEmbeddedGroup / regz

Generate zig code from ATDF or SVD files for microcontrollers.
MIT License
82 stars 29 forks source link

zig 0.10.0 compatibility #61

Open erazor-de opened 1 year ago

erazor-de commented 1 year ago

I tried to use regz to convert a svg for an STM32F103 and stumbled over the following problems:

The compiler complains

/home/stefan/workspace/stm32f103rb-test/src/registers.zig:31630:5: error: extern unions cannot contain fields of type 'fn() callconv(.C) void'
    C: fn () callconv(.C) void,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/stefan/workspace/stm32f103rb-test/src/registers.zig:31630:5: note: type has no guaranteed in-memory representation
/home/stefan/workspace/stm32f103rb-test/src/registers.zig:31630:5: note: use '*const ' to make a function pointer type
referenced by:
    InterruptVector: /home/stefan/workspace/stm32f103rb-test/src/registers.zig:31629:36
    unhandled: /home/stefan/workspace/stm32f103rb-test/src/registers.zig:31635:19
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

My corrected, working, definition looks so:

pub const InterruptVector = extern union {
    C: *const fn () callconv(.C) void,
    Naked: *const fn () callconv(.Naked) void,
    // Interrupt is not supported on arm
};
mattnite commented 1 year ago

oh sorry this issue passed through the cracks! I'm currently working on rearchitecting regz on the rewrite branch. Once I dub SVD parsing and codgen "good enough" it'll find itself in the main branch