[SAOC 2025] Improve importC Weekly Update #2
Emmanuel
emmankoko519 at gmail.com
Mon Sep 29 08:51:00 UTC 2025
Hi everyone,
This week, I had a long run with issue 20092 working to make
compound literals fully work in importC and it has been
successfully fixed and merged.
issue: https://github.com/dlang/dmd/issues/20092
The whole idea as discussed with my mentor was to create a
temporary variable and then export it with the addressof operator
during semantic analysis.
I did a lot of research into the expression semantics to fully
understand how the compound literals would fit together. for
local pointers, creating a temporary and making sure the variable
declaration and the variable expression were exported with the
`addressof` was enough.
for globals, it needed a little extra tinkering by making sure I
push the symbol into the symbol table for the address to be
picked up by the pointer.
PR : https://github.com/dlang/dmd/pull/21908#event-19961166923
`int *p = &(int){0};` in importC should get you a valid pointer
which you can work with and not necessarily creating an object
before pointing it as defined by the C standard.
More information about the Digitalmars-d
mailing list