Comment #0 by andrej.mitrovich — 2023-12-30T09:52:17Z
Here is 'clap.c' which is the pre-processed header file from a C library: https://gist.github.com/AndrejMitrovic/427866da4d3e9cd7dc307925f9eebdfa
---
dmd -m64 -c .\clap.c
C:\Apps\DMD\dmd2\windows\bin\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set
Error: C preprocess command C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64\cl.exe failed for file .\clap.c, exit status 2
---
In 2.105.3 this worked ok, but in 2.106.0 it fails.
I don't quite get if I'm just missing an import on my side or if it's a bug in Druntime?
Comment #1 by bugzilla — 2023-12-30T18:48:48Z
This problem surfaced after:
#include "sal.h"
was added by:
https://github.com/dlang/dmd/pull/15563
I'm wondering if the problem you're seeing is the INCLUDE environment variable that points to the VC include directory has not been set?
Comment #2 by flyboynw — 2023-12-31T23:46:24Z
This is due to MSFT's [SAL Annotations Library](https://learn.microsoft.com/en-us/cpp/c-runtime-library/sal-annotations?view=msvc-170) that they use as metadata. We added this because we need to disable this anytime an MSFT header gets included by ImportC.
This should be solved by using the Developer Command Prompt from Visual Studio as that will correctly setup the %INCLUDE% environment variable. In general, when using ImportC on Windows you should be invoking DMD from the Dev Prompt because you're using the whole compiler tool-chain.
Comment #3 by andrej.mitrovich — 2024-01-02T15:23:23Z
Yeah so it was indeed the missing include. Feel free to close, anyone else running into the same problem will likely find this bug report.
Though maybe we should make a suggestion on the ImportC page that if using Windows it's a good idea to set up vcvars / use the Dev Prompt.