mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Add a helper function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29049 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -24,6 +24,16 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
inline bool GetError(const std::string &Prefix, std::string *Dest) {
|
||||||
|
if (Dest == 0) return;
|
||||||
|
char *buffer = NULL;
|
||||||
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
|
||||||
|
*Dest = Prefix + buffer;
|
||||||
|
LocalFree(buffer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline void ThrowError(const std::string& msg) {
|
inline void ThrowError(const std::string& msg) {
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
Reference in New Issue
Block a user