⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shierror.h

📁 空战游戏flacon源码
💻 H
字号:
/***************************************************************************\
    ShiError.h
    Scott Randolph
    June 15, 1995

    Macros for dealing with fatal errors at runtime.
\***************************************************************************/
#ifndef SHIERROR_H
#define SHIERROR_H

#include <windows.h>
#include <stdio.h>
#include <assert.h>

// Routine to Convert a Windows error number into a string
#define PutErrorString(buf)  FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,					\
                                           NULL, GetLastError(),       					\
                                           MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),	\
                                           buf, sizeof(buf), NULL)


// ShiError is always kills the program even when not in debug mode.
#define ShiError( string )                                            				\
{																		  			\
	char	buffer[80];													  			\
																		  			\
	sprintf( buffer, "Error:  %0d  %s  %s", __LINE__, __FILE__, __DATE__ );			\
	MessageBox(NULL, buffer, string, MB_OK);										\
	exit(-1);															  			\
}

// ShiAssert compiles to code only when in debug mode.  Otherwise, the expression is not evaluated.
#ifdef _DEBUG

extern int shiAssertsOn,shiHardCrashOn;

#define ShiAssert( expr )																	\
	if (shiAssertsOn && !(expr)) {															\
	    static int	skipThisOne = FALSE;													\
																							\
		if (!skipThisOne) {																	\
			char	buffer[80];															  	\
			int		choice = IDRETRY;														\
																							\
			if (shiHardCrashOn)																\
				*((unsigned int *) 0x00) = 0;												\
			else {																			\
				sprintf( buffer, "Assertion at %0d  %s  %s", __LINE__, __FILE__, __DATE__ );\
				choice = MessageBox(NULL, buffer, "Failed:  " #expr,		 				\
									MB_ICONERROR | MB_ABORTRETRYIGNORE | MB_TASKMODAL);		\
				if (choice == IDABORT) {													\
					exit(-1);																\
				} else if (choice == IDRETRY) {												\
					__asm int 3																\
				} else if (choice == IDIGNORE) {											\
					skipThisOne = TRUE;														\
				}																			\
			}																				\
		}																					\
	}

#define ShiWarning( string )                                            			\
{																		  			\
	char	buffer[80];													  			\
																		  			\
	sprintf( buffer, "Error:  line %0d, %s on %s", __LINE__, __FILE__, __DATE__ );	\
	MessageBox(NULL, buffer, string, MB_OK);										\
}

#define ShiSetAsserts( expr )														\
{																					\
	shiAssertsOn = expr;															\
}

#define ShiSetHardCrash( expr )														\
{																					\
	shiHardCrashOn = expr;															\
}																					\

#else
#define ShiAssert( expr )

#define ShiWarning( string )

#define ShiSetAsserts( expr )														

#define ShiSetHardCrash( expr )

#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -