codegenDecl only works with var, let, and proc. Is there a way to change how type section generates C code? I mainly want to generate object types in C that looks like
struct sse_t { alignas(16) float sse_data[4];};
or
typedef __attribute__((aligned(16))) float sse_t[4];
Coming soon: https://github.com/nim-lang/Nim/pull/11077
For SSE, you can just use m128 type or GCC/LLVM vector extension (https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html), it will be properly aligned (tested up to AVX512).
The alignment is just an example. I would need may_alias and other things too.
The PR seems restrictive.
I'm pretty sure it's not possible at the type level.
Also beware when using codegendecl with proc, it overrides all Nim utilities like N_NIMCALL or N_INLINE: https://github.com/nim-lang/Nim/issues/10682
Support for codegenDecl for types sounds as interesting idea. File a feature request and PR is welcome.
What you can do now: emit your custom type using emit pragma and importc/importcpp declared type