In Phobos' etc/c/zlib/gzwrite.c file there is a workaround:
---
// needed on Win64 - MS __va_start intrinsic not supported by importC yet
#if __IMPORTC__
__builtin_va_start(va, format);
#else
va_start(va, format);
#endif
---
See https://github.com/dlang/phobos/pull/8865#issuecomment-1862006408
---
Argh, the Microsoft headers use something like this (`vadefs.h`) for x86_64:
```c
void __cdecl __va_start(va_list* , ...);
#define __crt_va_start_a(ap, x) ((void)(__va_start(&ap, x)))
```
The signature of their intrinsic isn't compatible with druntime's `va_start` (which takes the first param as `out` ref, not as explicit pointer), so I sadly don't see a way to handle this in druntime's `__builtins.di` (or `importc.h`).
---
Comment #1 by dlang-bot — 2024-01-01T20:27:53Z
@WalterBright updated dlang/dlang.org pull request #3752 "fix Issue 24312 - importC: Document workaround for using C symbols wh…" fixing this issue:
- fix Issue 24310 - importC: Document workaround for using C symbols which are also D keywords
https://github.com/dlang/dlang.org/pull/3752
Currently,
1. there is no va_start in importc.h
2. in __builtins.di there is:
alias __builtin_va_start = imported!"core.stdc.stdarg".va_start;
3. in Microsoft's stdarg.h there is:
#define va_start __crt_va_start
4. in core.stdc.stdarg there is:
void va_start(T)(out va_list ap, ref T parmn);
va_start() is an intrinsic built in to dmd.
Is __va_start() a Microsoft intrinsic?
Comment #4 by bugzilla — 2024-01-02T02:22:29Z
I suspect it might work if we added to stdarg.d:
void __va_start(T)(va_list* ap, ref T parmn)
{
va_start(*ap, parmn);
}
and to __builtins.di:
alias __va_start = imported!"core.stdc.stdarg".__va_start;
Comment #5 by dlang-bot — 2024-01-04T15:13:40Z
dlang/dlang.org pull request #3752 "fix Issue 24310 - importC: Document workaround for using C symbols wh…" was merged into master:
- 078629cbca561a697cb380481bcce6744c0a07ef by Walter Bright:
fix Issue 24310 - importC: Document workaround for using C symbols which are also D keywords
https://github.com/dlang/dlang.org/pull/3752
Comment #6 by dkorpel — 2024-01-04T15:25:24Z
Issue was linked to the wrong PR
Comment #7 by kinke — 2024-01-04T15:26:45Z
(In reply to Walter Bright from comment #4)
> I suspect it might work if we added to stdarg.d:
>
> void __va_start(T)(va_list* ap, ref T parmn)
> {
> va_start(*ap, parmn);
> }
>
> and to __builtins.di:
>
> alias __va_start = imported!"core.stdc.stdarg".__va_start;
I doubt it - this would probably need to be force-inlined at the AST level to work properly.
Comment #8 by robert.schadek — 2024-12-13T19:32:19Z