ada: fix i686-w64-mingw32 build

Message ID 41bd20b60779240f88014a4382311b294647fbc7.1765092502.git.sam@gentoo.org
State New
Headers
Series ada: fix i686-w64-mingw32 build |

Commit Message

Sam James Dec. 7, 2025, 7:28 a.m. UTC
  For __MINGW32__, we need to include <stdlib.h> for malloc.

gcc/ada/ChangeLog:
	PR ada/123037
	* rtinit.c: Include <stdlib.h> for __MINGW32__.
---
OK? I can swap the order of includes if preferred so stdlib.h comes before windows.h,
but I'm not familiar enough with Windows and I wasn't sure if <windows.h> would ever
set macros that stdlib.h needs.

 gcc/ada/rtinit.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Eric Botcazou Dec. 7, 2025, 10:05 p.m. UTC | #1
> For __MINGW32__, we need to include <stdlib.h> for malloc.
> 
> gcc/ada/ChangeLog:
> 	PR ada/123037
> 	* rtinit.c: Include <stdlib.h> for __MINGW32__.

OK, but please include it before mingw32.h and let's remove some duplication 
in the  process:


	PR ada/123037
	* rtinit.c [__MINGW32__]: Include <stdlib.h> and not <windows.h>.
	* rtfinal.c [__MINGW32__]: Do not include <windows.h>.
  

Patch

diff --git a/gcc/ada/rtinit.c b/gcc/ada/rtinit.c
index 598550c4051c..32c78d1f3c8b 100644
--- a/gcc/ada/rtinit.c
+++ b/gcc/ada/rtinit.c
@@ -73,6 +73,7 @@  int __gnat_rt_init_count = 0;
 #define WIN32_LEAN_AND_MEAN
 #include "mingw32.h"
 #include <windows.h>
+#include <stdlib.h>
 
 extern void __gnat_init_float (void);