Win32ada fails to compile with gcc 15.1.0

Downloaded Win32Ada-25.0.0 (version of Oct 2024) from the Adacore/Win32Ada repo.
Also installed the latest GNAT-FSF-build for Windows (downloaded from the Alire project (gnat-x86_64-windows64-15.1.0-2.tar.gz)). This build has gcc 15.1.0
When I try to compile Win32Ada with this gnat version it fails when compiling var.c.
When I compile Win32Ada-25.0.0 with the previous GNAT FSF build (that has gcc 14.1.0) the compilation is successful. Is this a known bug?

I’m curious, what’s error?

The error is:

\win32ada-25.0.0\src\var.c:157:19: error: too many arguments to function ‘func’; expected 0, have 50
157 | case 50: return (*func)(list50(p))
| ~^~~~~~
\win32ada-25.0.0\src\var.c:186:9: note: in expansion of macro ‘cases’
186 | cases(func, p);
| ^~~~~
completed 4 out of 161 (2%)…

compilation of var.c failed
<<<<
The above error is repeated is repeated 50 times, starting at “expected 0, have 1”

This is because of a change of default C standard (-std=gnu23) in GCC 15.

Basically, in C <23, an empty function prototype like int func() meant a function with an unknown number of arguments (and thus would accept any number of arguments). A function with 0 arguments, theoretically, should be typed as int func(void). In C23, this was changed to match modern expectations, and int func() now means a function taking 0 arguments.

GCC 15 changed the C standard version from gnu17 to gnu23. So now, C programs that were using this feature (notably here, to have a function pointer without an explicit number of arguments) won’t compile.

You can fix this by passing -std=gnu17 to your C compiler explicitly.

3 Likes

Thanks Cesar, that does the trick. All now compiles without errors/warnings.
However, when the script (mkwin32ada.bat) tries to create a library with ar.exe it fails (multiple times) with the message “bfd-plugins\libdep.a is either not designed to run on Windows or it contains an error”. ar.exe is found in the bin directory of the gnat-15.1.0 install.
Nevertheless, an apparently correct libwin32ada.a is produced …

1 Like

Yes this happened to me too when testing stuff on Windows. Deleting the libdep.a file removes the error messages for me, but I suspect that’s not a very good solution. I need to investigate this for a potential GNAT FSF 15 bugfix build.