www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ImportC GUID compilation problem with some Windows headers

reply Carl Sturtivant <sturtivant gmail.com> writes:
I'm running into this COM related issue with some Windows 
headers, in the case when each GUID is declared in such a file as 
follows.
```C
EXTERN_GUID(IID_IBlahBlahBlah, 0xabcdef12, 0x11d2, 0xab3a, 0xc0, 
0x4f, [...] );
```
and ImportC which is compiling `blah.c` containing only a few 
macro definitions and a single include of a header file say 
<blah.h> encounters these and responds with
```
[...] waffle.h(123): Error: variable `waffle.IID_IBlahBlahBlah` 
extern symbols cannot have initializers
```
Presumably MSVC simply compiles such files, but DMD's ImportC is 
too strict to do so. I've worked around this in some very dirty 
and inconvenient ways, but am hoping for a real solution of some 
kind. I want to use some of these IIDs and CLSIDs so I need to 
make these declarations work in some fashion. Inclusions are 
nested so these may be far from the header file I am including in 
`blah.c`. Any help appreciated.
Mar 20
parent reply Carl Sturtivant <sturtivant gmail.com> writes:
On Thursday, 21 March 2024 at 00:06:56 UTC, Carl Sturtivant wrote:
 ```C
 EXTERN_GUID(IID_IBlahBlahBlah, 0xabcdef12, 0x11d2, 0xab3a, 
 0xc0, 0x4f, [...] );
 ```
Has anyone successfully compiled an EXTERN_GUID declaration like this in a Windows header with ImportC using some C macro trickery for example?
Mar 21
parent reply Dave P. <dave287091 gmail.com> writes:
On Thursday, 21 March 2024 at 18:19:58 UTC, Carl Sturtivant wrote:
 On Thursday, 21 March 2024 at 00:06:56 UTC, Carl Sturtivant 
 wrote:
 ```C
 EXTERN_GUID(IID_IBlahBlahBlah, 0xabcdef12, 0x11d2, 0xab3a, 
 0xc0, 0x4f, [...] );
 ```
Has anyone successfully compiled an EXTERN_GUID declaration like this in a Windows header with ImportC using some C macro trickery for example?
I filed a bug for this: https://issues.dlang.org/show_bug.cgi?id=24447 I haven’t tried on a windows box and this is just from me grepping through header files, but maybe try to `#define EXTERN_C` as nothing in the meantime?
Mar 21
parent Carl Sturtivant <sturtivant gmail.com> writes:
On Thursday, 21 March 2024 at 22:33:17 UTC, Dave P. wrote:
 I filed a bug for this: 
 https://issues.dlang.org/show_bug.cgi?id=24447

 I haven’t tried on  a windows box and this is just from me 
 grepping through header files, but maybe try to `#define 
 EXTERN_C` as nothing in the meantime?
I'll give it a shot. Thanks for the bug report.
Mar 21