static char *rcsid = "$Id: safassrt.c,v 1.4 2006/07/30 11:56:11 cvs Exp $";
/*
*
* $RCSfile: safassrt.c,v $
* $Source: /cvs/common/safassrt.c,v $
* $Author: cvs $
* $Revision: 1.4 $
* $Date: 2006/07/30 11:56:11 $
* $State: Exp $
* Copyright (c) Stefan Kuhr
*
*
*
* $Log: safassrt.c,v $
* Revision 1.4 2006/07/30 11:56:11 cvs
* added deprecation macro for VS2005 builds
*
* Revision 1.3 2005/05/13 08:52:23 cvs
* Changed a lot of things to get rid of two different ASSERTs and allow for ASSERT MessageBoxes to even appear from services running under distinct user accounts. ALL ASSERTs are now actually inlined macros like in the MSVCRT.
*
* Revision 1.2 2003/10/17 15:54:11 cvs
* Now printing out the correct line and file information
*
* Revision 1.1 2003/08/23 14:20:14 cvs
* no message
*
*/
#define _CRT_SECURE_NO_DEPRECATE
#pragma warning (disable:4115 4305)
#include <windows.h>
#pragma warning (default:4115 4305)
#include "safassrt.h"
#ifdef _DEBUG
#include <stdio.h>
#include <signal.h>
#if defined (_M_IX86)
#define _DbgBreak() __asm { int 3 }
#elif defined (_M_ALPHA)
void _BPT();
#pragma intrinsic(_BPT)
#define _DbgBreak() _BPT()
#else /* defined (_M_ALPHA) */
#define _DbgBreak() DebugBreak()
#endif /* defined (_M_ALPHA) */
// anybuf _IOYOURBUF: stolen from the runtime's file2.h header file:
#define anybuf(s) ((s)->_flag & (_IOMYBUF|_IONBF|_IOYOURBUF))
#define _IOYOURBUF 0x0100
#ifndef MB_SERVICE_NOTIFICATION
#define MB_SERVICE_NOTIFICATION 0x00040000L
#endif //MB_SERVICE_NOTIFICATION
/*
* assertion format string for use with output to stderr
*/
static char _assertstring[] = "Assertion failed: %s, file %s, line %d\n";
static char * dblnewline = "\n\n";
static char * dotdotdot = "...";
static char * newline = "\n";
#define MAXLINELEN 60 /* max length for line in message box */
#define ASSERTBUFSZ (MAXLINELEN * 9) /* 9 lines in message box */
#define BOXINTRO "Assertion failed!"
#define PROGINTRO "Program: "
#define FILEINTRO "File: "
#define LINEINTRO "Line: "
#define EXPRINTRO "Expression: "
#define INFOINTRO "For information on how your program can cause an assertion\n" \
"failure, see the Visual C++ documentation on asserts"
#define HELPINTRO "(Press Retry to debug the application - JIT must be enabled)"
#define NEWLINESZ 1
#define DOTDOTDOTSZ 3
#define DBLNEWLINESZ 2
/// local prototypes:
static int __cdecl ___crtMessageBoxA(LPCSTR lpText, LPCSTR lpCaption, UINT uType);
/***
*_assert() - Display a message and abort
*
*Purpose:
* The assert macro calls this routine if the assert expression is
* true. By placing the assert code in a subroutine instead of within
* the body of the macro, programs that call assert multiple times will
* save space.
*
*Entry:
*
*Exit:
*
*Exceptions:
*
*******************************************************************************/
/*static void __cdecl __assert (
void *expr,
void *filename,
unsigned lineno
)*/
void SafeAssert(const char *expr, const char * filename, unsigned lineno, int __error_mode)
{
/*
* Build the assertion message, then write it out. The exact form
* depends on whether it is to be written out via stderr or the
* MessageBox API.
*/
if ( (__error_mode == _OUT_TO_STDERR) || ((__error_mode ==
_OUT_TO_DEFAULT) /*&& (__app_type == _CONSOLE_APP)*/) )
{
/*
* Build message and write it out to stderr. It will be of the
* form:
* Assertion failed: <expr>, file <filename>, line <lineno>
*/
if ( !anybuf(stderr) )
/*
* stderr is unused, hence unbuffered, as yet. set it to
* single character buffering (to avoid a malloc() of a
* stream buffer).
*/
(void) setvbuf(stderr, NULL, _IONBF, 0);
fprintf(stderr, _assertstring, expr, filename, lineno);
fflush(stderr);
}
else {
int nCode;
char * pch;
char assertbuf[ASSERTBUFSZ];
char progname[MAX_PATH];
/*
* Line 1: box intro line
*/
strcpy( assertbuf, BOXINTRO );
strcat( assertbuf, dblnewline );
/*
* Line 2: program line
*/
strcat( assertbuf, PROGINTRO );
if ( !GetModuleFileNameA( NULL, progname, MAX_PATH ))
strcpy( progname, "<program name unknown>");
pch = (char *)progname;
/* sizeof(PROGINTRO) includes the NULL terminator */
if ( sizeof(PROGINTRO) + strlen(progname) + NEWLINESZ > MAXLINELEN )
{
pch += (sizeof(PROGINTRO) + strlen(progname) + NEWLINESZ) - MAXLINELEN;
strncpy( pch, dotdotdot, DOTDOTDOTSZ );
}
strcat( assertbuf, pch );
strcat( assertbuf, newline );
/*
* Line 3: file line
*/
strcat( assertbuf, FILEINTRO );
/* sizeof(FILEINTRO) includes the NULL terminator */
if ( sizeof(FILEINTRO) + strlen(filename) + NEWLINESZ >
MAXLINELEN )
{
/* too long. use only the first part of the filename string */
strncat( assertbuf, filename, MAXLINELEN - sizeof(FILEINTRO)
- DOTDOTDOTSZ - NEWLINESZ );
/* append trailing "..." */
strcat( assertbuf, dotdotdot );
}
else
/* plenty of room on the line, just append the filename */
strcat( assertbuf, filename );
strcat( assertbuf, newline );
/*
* Line 4: line line
*/
strcat( assertbuf, LINEINTRO );
_itoa( lineno, assertbuf + strlen(assertbuf), 10 );
strcat( assertbuf, dblnewline );
/*
* Line 5: message line
*/
strcat( assertbuf, EXPRINTRO );
/* sizeof(HELPINTRO) includes the NULL terminator */
if ( strlen(assertbuf) +
strlen(expr) +
2*DBLNEWLINESZ +
sizeof(INFOINTRO)-1 +
sizeof(HELPINTRO) > ASSERTBUFSZ )
{
strncat( assertbuf, expr,
ASSERTBUFSZ -
(strlen(assertbuf) +
DOTDOTDOTSZ +
2*DBLNEWLINESZ +
sizeof(INFOINTRO)-1 +
sizeof(HELPINTRO)) );
strcat( assertbuf, dotdotdot );
}
else
strcat( assertbuf, expr );
strcat( assertbuf, dblnewline );
/*
* Line 6, 7: info line
*/
strcat(assertbuf, INFOINTRO);
strcat( assertbuf, dblnewline );
/*
* Line 8: help line
*/
strcat(assertbuf, HELPINTRO);
/*
* Write out via MessageBox
*/
nCode = ___crtMessageBoxA(assertbuf,
"Microsoft Visual C++ Runtime Library",
MB_DEFAULT_DESKTOP_ONLY|MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL);
/* Abort: abort the program */
if (nCode == IDABORT)
{
/* raise abort signal */
raise(SIGABRT);
/* We usually won't get here, but it's possible that
SIGABRT was ignored. So exit the program anyway. */
没有合适的资源?快使用搜索试试~ 我知道了~
VC++控件演示集合
共66个文件
cpp:22个
h:15个
bmp:7个
1星 需积分: 9 6 下载量 128 浏览量
2011-05-28
18:01:14
上传
评论
收藏 223KB ZIP 举报
温馨提示
VC++控件演示集合:包括编辑、下拉列表、进度条、日历等。其中下拉列表带图标
资源推荐
资源详情
资源评论
收起资源包目录
autoaero.zip (66个子文件)
autoaero
aerohdrs
specstrings_adt.h 90B
specstrings_strict.h 99B
sal.h 3KB
common
safassrt.c 10KB
aerocmbo.cpp 6KB
aerobutn.cpp 27KB
aerotree.cpp 3KB
aerosubc.cpp 33KB
aerospin.cpp 6KB
aeroedit.cpp 6KB
aeroanim.cpp 28KB
aeroglss.cpp 17KB
p4710.h 399B
aeroprgs.cpp 4KB
aeroslid.cpp 27KB
aerodtpk.cpp 3KB
aerosubc.h 3KB
aerostat.cpp 11KB
aerolctr.cpp 4KB
aeroipad.cpp 6KB
aerohdr.cpp 2KB
safassrt.h 2KB
aaeroint.h 5KB
aeroglss.h 4KB
aerolbox.cpp 3KB
autoaero
autoaero.dsw 567B
autoaero.vcproj 137KB
autoaero.dsp 18KB
uRelease
autoaero.exe 88KB
autoaeroDlg.cpp 10KB
MonthCal.h 807B
StdAfx.cpp 406B
resource.h 3KB
autoaero.cpp 2KB
.cvsignore 150B
MixedCtrlDlg.h 820B
x64Release
autoaero.exe 102KB
autoaeroDlg.h 3KB
autoaero.rc 14KB
autoaero.sln 2KB
StdAfx.h 2KB
RichEditDlg.h 812B
x64uRelease
autoaero.exe 103KB
Release
autoaero.exe 88KB
res
bmtreefi.bmp 374B
CVS
Entries 503B
Entries.Extra 187B
Repository 14B
Baserev 0B
Entries.Old 503B
Entries.Extra.Old 187B
Root 42B
bmp00002.bmp 374B
bmtreebi.bmp 374B
bitmap1.bmp 1KB
search.avi 20KB
bmp00003.bmp 374B
bmp00001.bmp 374B
bmtreedo.bmp 374B
autoaero.ico 1KB
autoaero.rc2 424B
autoaero.exe.manifest 600B
MonthCal.cpp 2KB
autoaero.h 1KB
RichEditDlg.cpp 3KB
MixedCtrlDlg.cpp 3KB
共 66 条
- 1
资源评论
- jj_1222012-12-26release的。。我是debug的。晕。
liuchangyin
- 粉丝: 12
- 资源: 39
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功