File: quit.cpp

package info (click to toggle)
piler 0~20140707-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 360 kB
  • sloc: cpp: 5,369; makefile: 39
file content (38 lines) | stat: -rwxr-xr-x 690 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "piler2.h"

#ifdef WIN32
#define _WIN32_WINNT 0x0400
#include <windows.h>

void Break()
	{
	DebugBreak();
	}
#endif

// Exit immediately with error message, printf-style.
void Quit(const char szFormat[], ...)
	{
	va_list ArgList;
	char szStr[4096];

	va_start(ArgList, szFormat);
	vsprintf(szStr, szFormat, ArgList);

	fprintf(stderr, "\n*** FATAL ERROR ***  %s %s\n", g_ProcessName, szStr);

	Log("\n*** FATAL ERROR ***  ");
	Log("%s\n", szStr);

#if	DEBUG
#ifdef WIN32
	if (IsDebuggerPresent())
		{
		int iBtn = MessageBox(NULL, szStr, "piler", MB_ICONERROR | MB_OKCANCEL);
		if (IDCANCEL == iBtn)
			Break();
		}
#endif
#endif
	exit(1);
	}