4619a4fa889b50890268da386e0a4754049dfc28
1 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
8 static const char formatstr
[] =
9 "Assertion failed!\n\n"
14 "Press Retry to debug the application\n";
20 void _assert(const char *exp
, const char *file
, unsigned line
)
22 int (WINAPI
*pMessageBoxA
)(HWND
, LPCTSTR
, LPCTSTR
, UINT
);
29 /* Assertion failed at foo.c line 45: x<y */
30 fprintf(stderr
, "Assertion failed at %s line %d: %s\n", file
, line
, exp
);
31 FIXME("Assertion failed at %s line %d: %s\n", file
, line
, exp
);
33 /* Get MessageBoxA function pointer */
34 hmodUser32
= LoadLibrary("user32.dll");
35 pMessageBoxA
= (PVOID
)GetProcAddress(hmodUser32
, "MessageBoxA");
41 /* Get the file name of the module */
42 len
= GetModuleFileNameA(NULL
, achProgram
, 40);
44 /* Calculate full length of the message */
45 len
+= sizeof(formatstr
) + len
+ strlen(exp
) + strlen(file
);
47 /* Allocate a buffer */
48 pszBuffer
= malloc(len
+ 1);
50 /* Format a message */
51 _snprintf(pszBuffer
, len
, formatstr
, achProgram
, file
, line
, exp
);
53 /* Display a message box */
54 iResult
= pMessageBoxA(NULL
,
56 "ReactOS C Runtime Library",
57 MB_ABORTRETRYIGNORE
| MB_ICONERROR
);
61 /* Does the user want to abort? */
62 if (iResult
== IDABORT
)
67 /* Does the user want to debug? */
68 if (iResult
== IDRETRY
)
70 DbgRaiseAssertionFailure();