On Thu, Jan 29, 2026 at 10:39 AM Torbjörn SVENSSON
<[email protected]> wrote:
>
> Without this change, building with MinGW v9.0.0 or earlier gives the follwing 
> error:
>
> gcc/diagnostics/sarif-sink.cc:23:10: fatal error: afunix.h: No such file or 
> directory
>  #include <afunix.h>
>           ^~~~~~~~~~
> compilation terminated.
> Makefile:1219: recipe for target 'diagnostics/sarif-sink.o' failed
> make[1]: *** [diagnostics/sarif-sink.o] Error 1
>
>
> Ok for trunk?
>
> --
>
> afunix.h was first included in MinGW 10.0.0.  For earlier versions, fall
> back to internal definition.
This structure is not defined anywhere in older versions of mingw?
Maybe we should put this in definition in a header file that gets included.
So something like:
```
#if (__MINGW64_VERSION_MAJOR - 0) >= 10
#include <afunix.h>
#endif
#include "mingw-workarounds.h"
```

And then inside mingw-workarounds.h define the struct for
`(__MINGW64_VERSION_MAJOR - 0) < 10`.
or something to that effect.

Thanks,
Andrew Pinski

>
> gcc/ChangeLog:
>
>         * diagnostics/sarif-sink.cc: Conditionally include afunix.h
>           depending on MinGW version used.
>
> Signed-off-by: Torbjörn SVENSSON <[email protected]>
> ---
>  gcc/diagnostics/sarif-sink.cc | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/gcc/diagnostics/sarif-sink.cc b/gcc/diagnostics/sarif-sink.cc
> index 78743df7f1d..d4b8c77f8b8 100644
> --- a/gcc/diagnostics/sarif-sink.cc
> +++ b/gcc/diagnostics/sarif-sink.cc
> @@ -20,8 +20,15 @@ along with GCC; see the file COPYING3.  If not see
>
>  #ifdef __MINGW32__
>  #include <winsock2.h>
> +#if (__MINGW64_VERSION_MAJOR - 0) >= 10
>  #include <afunix.h>
>  #else
> +struct sockaddr_un {
> +  ADDRESS_FAMILY sun_family;
> +  char sun_path[108];
> +};
> +#endif
> +#else
>  #include <sys/un.h>
>  #include <sys/socket.h>
>  #endif
> --
> 2.43.0
>

Reply via email to