[SAOC 2026] ImportC Weekly Update #9
Niyati Jain
niyati.jainn15 at gmail.com
Wed Nov 25 12:44:24 UTC 2026
I'm a bit late for the update this week, as I was busy with my
semester exams.
so, this week I started working on Milestone 3, macro translation
for curl's and SDL's headers.
Firstly, while reading through curl's header, I came across
`#pragma comment(lib, "name")` being silently dropped by
ImportC's `#pragma` handling (#21265). MSVC headers lean on this
a lot to pull in the right import library, kernel32, ws2_32,
whatever the function needs, and ImportC just had no case for
`comment` at all in its pragma dispatch. So it was treating it
like any other unrecognized pragma and skipping it. Fixed it by
recognizing the `lib` comment-type and feeding the library name
straight into D's existing `pragma(lib, "name")` mechanism.
While I was looking at curl's header for that, I noticed `#define
CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL`, a bare identifier alias
with no parens anywhere ,that turned out ImportC already handles
the equivalent case for a bare function-like macro call since
#22347 (https://github.com/dlang/dmd/pull/22347), the reasoning
being that a function call already has the highest precedence in
C, so wrapping it in a D template function is always safe. A lone
identifier is exactly as safe by the same argument, so I just
extended that same check. curl.h actually has dozens of these
aliases once to start looking (`CURLE_FUNCTION_NOT_FOUND`,
`CURLOPT_ENCODING`, and a lot more), and SDL3's own
`SDL_SIZE_MAX` is the same shape.
PR : (https://github.com/dlang/dmd/pull/24420).
Also spent some time on #21815
(https://github.com/dlang/dmd/issues/21815) , and it turns out
the remaining `__imp_MapViewOfFileNuma2` symbol there isn't a
header-pragma problem at all, `MapViewOfFile2` is forceinline and
calls it directly, so the real issue is just `kernel32.lib` not
being on the link line which is a dmd default-linking question.
Next week, I'll be looking at what else in curl's and SDL's
headers needs the same kind of macro handling.
Any feedback or suggestion is highly welcomed.
Best,
Niyati
More information about the Digitalmars-d
mailing list