LLVM API Documentation
00001 //===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by Reid Spencer 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 Unix implementations. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 //===----------------------------------------------------------------------===// 00015 //=== WARNING: Implementation here must contain only generic UNIX code that 00016 //=== is guaranteed to work on all UNIX variants. 00017 //===----------------------------------------------------------------------===// 00018 00019 #include "llvm/Config/config.h" // Get autoconf configuration settings 00020 #include "windows.h" 00021 #include <cassert> 00022 #include <string> 00023 00024 inline void ThrowError(const std::string& msg) { 00025 char *buffer = NULL; 00026 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, 00027 NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL); 00028 std::string s(msg); 00029 s += buffer; 00030 LocalFree(buffer); 00031 throw s; 00032 } 00033 00034 inline void ThrowErrno(const std::string& prefix) { 00035 ThrowError(prefix + ": " + strerror(errno)); 00036 }