Build error with GCC 14.2.0 on MinGW due to implicit declaration of function 'vasprintf'
Describe the bug
Build error with GCC 14.2.0 on MinGW on line
https://github.com/HDFGroup/hdf5/blob/0fe0459fc24d71be13d5f266513c2832b525671b/src/H5private.h#L881-L887
This is the compiler output:
In file included from C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\37b6ace5000ac67136a8ecfe8d28158bec4e4303\src\src\H5Eint.c:31:
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\37b6ace5000ac67136a8ecfe8d28158bec4e4303\src\src\H5Eint.c: In function 'H5E__set_stack_entry':
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\37b6ace5000ac67136a8ecfe8d28158bec4e4303\src\src\H5private.h:883:34: error: implicit declaration of function 'vasprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration]
883 | #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
| ^~~~~~~~~
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\37b6ace5000ac67136a8ecfe8d28158bec4e4303\src\src\H5Eint.c:1591:13: note: in expansion of macro 'HDvasprintf'
1591 | if (HDvasprintf(&desc, fmt, *ap) < 0)
| ^~~~~~~~~~~
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\37b6ace5000ac67136a8ecfe8d28158bec4e4303\src\src\H5private.h:883:34: warning: nested extern declaration of 'vasprintf' [-Wnested-externs]
883 | #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
| ^~~~~~~~~
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\37b6ace5000ac67136a8ecfe8d28158bec4e4303\src\src\H5Eint.c:1591:13: note: in expansion of macro 'HDvasprintf'
1591 | if (HDvasprintf(&desc, fmt, *ap) < 0)
| ^~~~~~~~~~~
mingw32-make[2]: *** [src\CMakeFiles\hdf5-static.dir\build.make:1126: src/CMakeFiles/hdf5-static.dir/H5Eint.c.obj] Error 1
mingw32-make[2]: *** Waiting for unfinished jobs....
mingw32-make[1]: *** [CMakeFiles\Makefile2:266: src/CMakeFiles/hdf5-static.dir/all] Error 2
mingw32-make: *** [Makefile:135: all] Error 2
hdf5/1.14.5:
hdf5/1.14.5: ERROR: Package '37b6ace5000ac67136a8ecfe8d28158bec4e4303' build failed
Note that GCC 12.2.0 succeed with a warning though:
In file included from C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\8ab3a07e0a1cc9bdc28057905d33b5e79ddc844a\src\src\H5Eint.c:31:
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\8ab3a07e0a1cc9bdc28057905d33b5e79ddc844a\src\src\H5Eint.c: In function 'H5E__set_stack_entry':
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\8ab3a07e0a1cc9bdc28057905d33b5e79ddc844a\src\src\H5private.h:883:34: warning: implicit declaration of function 'vasprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration]
883 | #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
| ^~~~~~~~~
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\8ab3a07e0a1cc9bdc28057905d33b5e79ddc844a\src\src\H5private.h:883:34: note: in definition of macro 'HDvasprintf'
883 | #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
| ^~~~~~~~~
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\8ab3a07e0a1cc9bdc28057905d33b5e79ddc844a\src\src\H5private.h:883:34: warning: nested extern declaration of 'vasprintf' [-Wnested-externs]
883 | #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
| ^~~~~~~~~
C:\Users\runneradmin\.conan\data\hdf5\1.14.5\_\_\build\8ab3a07e0a1cc9bdc28057905d33b5e79ddc844a\src\src\H5private.h:883:34: note: in definition of macro 'HDvasprintf'
883 | #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
| ^~~~~~~~~
Note that for both outputs vasprint was detected:
-- Looking for vasprintf
-- Looking for vasprintf - found
The error appeared with the windows-latest workflow change as announced by https://github.com/actions/runner-images/issues/12677.
Expected behavior
Compilation should not fail. The warning/error needs be fixed or at least circumvented.
Platform (please complete the following information)
- HDF5 version: 1.14.5 (0fe0459fc24d71be13d5f266513c2832b525671b)
- OS: Windows Server 2025
- Compiler and version: GCC 14.2.0 MinGW
- Build system: CMake 3.30.x via Conan 1.x
@tbeu, @jhendersonHDF, we're encountering build failures on Github Actions with the very same error messages. Are there any updates here? Thanks!
Hi @slayoo,
We're currently in the middle of finishing up a release, so may not be able to get to this issue for a little bit. Have you tried with the latest HDF5 development branch? We're currently testing MinGW on windows-latest (see https://github.com/HDFGroup/hdf5/blob/develop/.github/workflows/msys2.yml and https://github.com/HDFGroup/hdf5/actions/runs/18652476869/job/53173487439) and it seems that vasprintf is both found and also used with GCC 15.2.0. Maybe there's a difference in the way that we configure HDF5 for testing vs. how others do?
It seems windows-2022 runner now also comes with GCC 14, hence there is no working CI via GitHub Actions possible with MinGW.
See https://github.com/actions/runner-images/pull/13172
Thanks for the follow ups. We've ended up with this addition in CMakeLists.txt to workaround it:
if (MINGW)
# https://github.com/HDFGroup/hdf5/issues/5885
target_compile_definitions(hdf5-static PRIVATE _GNU_SOURCE)
endif()
Is it available in v2.0.0?
Edit: I needed to patch it differently, see https://github.com/tbeu/ModelicaTableAdditions/commit/97d8f0b504b0eb781428df43ac2aed8ab88240c4. Thanks.
@tbeu I've put this on our 2.1.x milestone to look at. It should be a fairly simple fix, though I'd like to figure out why our CI isn't running into the issue.