>
> > It sounds like guiddef.h should probably check the GCC major version.
> > Based on the tests people have reported in this thread, I would guess
> that
> > for GCC 6 and above the selectany attribute on the declaration is
> required,
> > while on GCC 5 and below the selectany attribute on the declaration is
> > forbidden. Or we could get fancy and add a test to the configure script
> to
> > figure out which is the case.
> Both require citation from GCC documentation. But neither is an optimal
> solution IMHO. I suggest we ensure each GUID is defined only once then
> remove that attribute completely.
>

When you say "optimal", what are you optimizing for?

I'm trying to optimize for being able to port code from Visual Studio to
mingw-w64.  Microsoft has example code (UsbView) that has a header file
that includes the windows.h, followed by initguid.h, followed by
winioctl.h.  You can see the header file here:

https://github.com/Microsoft/Windows-driver-samples/blob/master/usb/usbview/uvcview.h

The UsbView code uses that header file in several different translation
units, so you end up having a bunch of duplicate GUID definitions for all
the GUIDs defined in winioctl.h, like GUID_DEVINTERFACE_DISK.  To prevent
multiple definition errors, the Microsoft header files using the selectany
attribute.

I don't know why Microsoft engineered such a complicated solution for
defining GUIDs, but they did, and I would think we should try to make our
header files compatible with it.  If it just takes a few preprocessor if
statements that check the GCC version, that seems OK.

--David
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to