Skip to content

Commit

Permalink
Include shlwapi.h explicitly on Windows (#2407)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mkitti authored Jan 17, 2023
1 parent 5543d6e commit 720e04e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions config/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
1 change: 1 addition & 0 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand Down

0 comments on commit 720e04e

Please sign in to comment.