assert.cc

来自「cygwin, 著名的在win32下模拟unix操作系统的东东」· CC 代码 · 共 56 行

CC
56
字号
/* assert.cc: Handle the assert macro for WIN32.   Copyright 1997, 1998, 2000, 2001 Red Hat, Inc.This file is part of Cygwin.This software is a copyrighted work licensed under the terms of theCygwin license.  Please consult the file "CYGWIN_LICENSE" fordetails. */#include "winsup.h"#include "security.h"#include <wingdi.h>#include <winuser.h>#include <assert.h>#include <stdlib.h>#include <stdio.h>/* This function is called when the assert macro fails.  This will   override the function of the same name in newlib.  */extern "C" void__assert (const char *file, int line, const char *failedexpr){  HANDLE h;  /* If we don't have a console in a Windows program, then bring up a     message box for the assertion failure.  */  h = CreateFile ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, &sec_none_nih,		  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);  if (h == INVALID_HANDLE_VALUE)    {      char *buf;      buf = (char *) alloca (100 + strlen (failedexpr));      __small_sprintf (buf, "Failed assertion\n\t%s\nat line %d of file %s",		failedexpr, line, file);      MessageBox (NULL, buf, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);    }  else    {      CloseHandle (h);      small_printf ("assertion \"%s\" failed: file \"%s\", line %d\n",		    failedexpr, file, line);    }#ifdef DEBUGGING  try_to_debug ();#endif  abort ();	// FIXME: Someday this should work.  /* NOTREACHED */}

⌨️ 快捷键说明

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