Include shlwapi.h explicitly on Windows (#2407)

* Include shlwapi.h explicitly

* Add shlwapi library to LINK_LIB when header is detected

Looking for StrStrIA in the shlwapi library is not reliable due
to stdcall on mingw32.
This commit is contained in:
Mark Kittisopikul 2023-01-17 10:27:25 -05:00 committed by GitHub
parent 5543d6eb36
commit 720e04e196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -131,6 +131,8 @@ CHECK_INCLUDE_FILE_CONCAT ("netdb.h" ${HDF_PREFIX}_HAVE_NETDB_H)
CHECK_INCLUDE_FILE_CONCAT ("arpa/inet.h" ${HDF_PREFIX}_HAVE_ARPA_INET_H)
if (WINDOWS)
CHECK_INCLUDE_FILE_CONCAT ("shlwapi.h" ${HDF_PREFIX}_HAVE_SHLWAPI_H)
# Checking for StrStrIA in the library is not relaible for mingw32 to stdcall
set (LINK_LIBS ${LINK_LIBS} "shlwapi")
endif ()
## Check for non-standard extension quadmath.h
@ -156,10 +158,6 @@ if (MINGW OR NOT WINDOWS)
CHECK_LIBRARY_EXISTS_CONCAT ("wsock32" gethostbyname ${HDF_PREFIX}_HAVE_LIBWSOCK32)
endif ()
if (WINDOWS)
CHECK_LIBRARY_EXISTS_CONCAT ("shlwapi" StrStrIA ${HDF_PREFIX}_HAVE_SHLWAPI)
endif ()
# UCB (BSD) compatibility library
CHECK_LIBRARY_EXISTS_CONCAT ("ucb" gethostname ${HDF_PREFIX}_HAVE_LIBUCB)

View File

@ -125,6 +125,7 @@
#include <direct.h> /* For _getcwd() */
#include <io.h> /* POSIX I/O */
#include <winsock2.h> /* For GetUserName() */
#include <shlwapi.h> /* For StrStrIA */
#ifdef H5_HAVE_THREADSAFE
#include <process.h> /* For _beginthread() */