Skip to content

Commit

Permalink
lib/Support/Windows/Windows.h: Autoconf provides predefined macros (_…
Browse files Browse the repository at this point in the history
…WIN32_WINNT, etc.).

_WIN32_WINNT, _WIN32_IE, WIN32_LEAN_AND_MEAN
They affect seeking declarations at configure.
  • Loading branch information
chapuni committed Feb 4, 2011
1 parent e69a9f8 commit 45be38c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
7 changes: 7 additions & 0 deletions autoconf/configure.ac
Expand Up @@ -1218,6 +1218,13 @@ dnl===-----------------------------------------------------------------------===

AC_CHECK_LIB(m,sin)
if test "$llvm_cv_os_type" = "MingW" ; then
AC_DEFINE([_WIN32_WINNT],[0x0500],
[We require Windows 2000 API.])
AC_DEFINE([_WIN32_IE],[0x0500],
[MinGW at it again.])
AC_DEFINE([WIN32_LEAN_AND_MEAN],[],
[We don't need fullset of Windows headers.])

AC_CHECK_LIB(imagehlp, main)
AC_CHECK_LIB(psapi, main)
fi
Expand Down
6 changes: 6 additions & 0 deletions cmake/config-ix.cmake
Expand Up @@ -86,6 +86,12 @@ if( NOT LLVM_ON_WIN32 )
endif()

# function checks
if (LLVM_ON_WIN32)
add_llvm_config_definition(_WIN32_WINNT 0x0500)
add_llvm_config_definition(_WIN32_IE 0x0500)
add_llvm_config_definition(WIN32_LEAN_AND_MEAN 1)
endif ()

check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT)
Expand Down
16 changes: 16 additions & 0 deletions configure
Expand Up @@ -13553,6 +13553,22 @@ fi

if test "$llvm_cv_os_type" = "MingW" ; then

cat >>confdefs.h <<\_ACEOF
#define _WIN32_WINNT 0x0500
_ACEOF


cat >>confdefs.h <<\_ACEOF
#define _WIN32_IE 0x0500
_ACEOF


cat >>confdefs.h <<\_ACEOF
#define WIN32_LEAN_AND_MEAN
_ACEOF



{ echo "$as_me:$LINENO: checking for main in -limagehlp" >&5
echo $ECHO_N "checking for main in -limagehlp... $ECHO_C" >&6; }
if test "${ac_cv_lib_imagehlp_main+set}" = set; then
Expand Down
9 changes: 9 additions & 0 deletions include/llvm/Config/config.h.cmake
Expand Up @@ -612,6 +612,15 @@
/* Define if use udis86 library */
#undef USE_UDIS86

/* We don't need fullset of Windows headers. */
#cmakedefine WIN32_LEAN_AND_MEAN

/* MinGW at it again. */
#cmakedefine _WIN32_IE ${_WIN32_IE}

/* We require Windows 2000 API. */
#cmakedefine _WIN32_WINNT ${_WIN32_WINNT}

/* Define to empty if `const' does not conform to ANSI C. */
#undef const

Expand Down
9 changes: 9 additions & 0 deletions include/llvm/Config/config.h.in
Expand Up @@ -623,6 +623,15 @@
/* Define if use udis86 library */
#undef USE_UDIS86

/* We don't need fullset of Windows headers. */
#undef WIN32_LEAN_AND_MEAN

/* MinGW at it again. */
#undef _WIN32_IE

/* We require Windows 2000 API. */
#undef _WIN32_WINNT

/* Define to empty if `const' does not conform to ANSI C. */
#undef const

Expand Down
5 changes: 0 additions & 5 deletions lib/Support/Windows/Windows.h
Expand Up @@ -16,11 +16,6 @@
//=== is guaranteed to work on *all* Win32 variants.
//===----------------------------------------------------------------------===//

// Require at least Windows 2000 API.
#define _WIN32_WINNT 0x0500
#define _WIN32_IE 0x0500 // MinGW at it again.
#define WIN32_LEAN_AND_MEAN

#include "llvm/Config/config.h" // Get build system configuration settings
#include <Windows.h>
#include <ShlObj.h>
Expand Down

1 comment on commit 45be38c

@asl
Copy link
Contributor

@asl asl commented on 45be38c Feb 5, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good way of doing thing. You're passing platform-dependent macros to all files, even those which do not include windows.h. These #define's should be localized in windows-only places (e.g. libSupport)

Please sign in to comment.