diff options
author | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
commit | 1fd5e000ace55b323124c7e556a7a864b972a5c4 (patch) | |
tree | dc4fcf1e5e22a040716ef92c496b8d94959b2baa /winsup/cygwin/assert.cc | |
parent | 369d8a8fd5e887eca547bf34bccfdf755c9e5397 (diff) | |
download | cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.gz cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.bz2 cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.zip |
import winsup-2000-02-17 snapshot
Diffstat (limited to 'winsup/cygwin/assert.cc')
-rw-r--r-- | winsup/cygwin/assert.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/winsup/cygwin/assert.cc b/winsup/cygwin/assert.cc new file mode 100644 index 000000000..98acb6d88 --- /dev/null +++ b/winsup/cygwin/assert.cc @@ -0,0 +1,50 @@ +/* assert.cc: Handle the assert macro for WIN32. + + Copyright 1997, 1998, 2000 Cygnus Solutions. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#include "winsup.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 = CreateFileA ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, &sec_none_nih, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE || h == 0) + { + char *buf; + + buf = (char *) alloca (100 + strlen (failedexpr)); + siprintf (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); + (void) fiprintf (stderr, + "assertion \"%s\" failed: file \"%s\", line %d\n", + failedexpr, file, line); + } + + abort (); + + /* NOTREACHED */ +} |