blob: ab6b3c2b4984b53c0312bff9476678868120152e [file] [log] [blame]
Reid Spencer0b22ba42004-09-15 05:48:11 +00001//===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines things specific to Unix implementations.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only generic UNIX code that
16//=== is guaranteed to work on all UNIX variants.
17//===----------------------------------------------------------------------===//
18
19#include "llvm/Config/config.h" // Get autoconf configuration settings
20#include "windows.h"
21#include <cassert>
22#include <string>
23
24inline void ThrowError(const std::string& msg) {
25 char *buffer = NULL;
26 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
27 NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
28 std::string s(msg);
29 s += buffer;
30 LocalFree(buffer);
31 throw s;
32}
33
Reid Spencer6b09db52004-11-15 17:21:57 +000034inline void ThrowErrno(const std::string& prefix) {
35 ThrowError(prefix + ": " + strerror(errno));
36}