www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/10/15:15:34

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help! Using Allegro with assert()
Date: Sun, 9 Feb 1997 11:41:55 +0000
Organization: None
Distribution: world
Message-ID: <81ScKDADgb$yEw8N@talula.demon.co.uk>
References: <5djkv1$gmf$1 AT newton DOT pacific DOT net DOT sg>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 28
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Victor writes:
>When I use Allegro with assert() function, I'm getting this message
>when the program quits due to false statement passed to assert() :
>
>Shutting down Allegro
>Exiting due to signal SIGABRT
>
>instead of the line in which error occurred.
>
>Is there any way to get the line number?

You'll need to write a custom assert macro in order for this to work.
The standard libc implementation prints the line number to stderr, but
since your program is in graphics mode at the time, this output isn't
visible. It then raises SIGABRT, which is trapped by Allegro and causes
a clean shutdown (switching back to text mode, removing interrupt
handlers, etc). For the assert message to be visible, you'll need to
alter the routine __dj_assert() (in djgpp\src\libc\ansi\assert\assert.c)
to call allegro_exit() before the call to fprintf().

Alternatively, you could just redirect stderr into a file and examine it
later, or pipe it into more. For example, running 'myprog | more' ought
to make the output visible (or 'myprog |& more' if you are using 4dos).

/*
 *  Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
 *  Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
 */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019