LLVM API Documentation

Win32.h

Go to the documentation of this file.
00001 //===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by Jeff Cohen and is distributed under the
00006 // University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines things specific to Win32 implementations.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 //===----------------------------------------------------------------------===//
00015 //=== WARNING: Implementation here must contain only generic Win32 code that
00016 //===          is guaranteed to work on *all* Win32 variants.
00017 //===----------------------------------------------------------------------===//
00018 
00019 // Require at least Windows 2000 API.
00020 #define _WIN32_WINNT 0x0500
00021 
00022 #include "llvm/Config/config.h"     // Get autoconf configuration settings
00023 #include "windows.h"
00024 #include <cassert>
00025 #include <string>
00026 
00027 inline void ThrowError(const std::string& msg) {
00028   char *buffer = NULL;
00029   FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
00030       NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
00031   std::string s(msg);
00032   s += buffer;
00033   LocalFree(buffer);
00034   throw s;
00035 }
00036 
00037 inline void ThrowErrno(const std::string& prefix) {
00038     ThrowError(prefix + ": " + strerror(errno));
00039 }