Mail Archives: djgpp/1997/02/10/15:15:34
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 -