Re: curses_trace() - version 6.6
Björn Försterling <[email protected]>
| Newsgroups | gmane.comp.lib.ncurses.bugs |
|---|---|
| Message-ID | <CA+D_Ns-2-pLZrzSdWuQ-2ud30LkGGmS-Z2KTXvx9kti8hQeP-g@mail.gmail.com> |
Thank you for the response. For me the man page sounded like "curses_trace()" is always available no matter how you compile the library. I thought calling the function twice to check for the return code is a little awkward. But if that is the official way to do it - I'm fine with it. :) On Wed, Aug 5, 2026 at 9:09 PM Thomas Dickey <[email protected]> wrote: > On Wed, Aug 05, 2026 at 07:41:24PM +0200, Björn Försterling wrote: > > Hello, > > > > the man page "curs_trace" says: > > > The curses_trace function is always available [...] > > > > But you have to configure ncurses with "--with-trace" so that > > `curses_trace()` actually outputs to a "trace" file, which is not clear > > from the man page. > > The man page does say that: > > DESCRIPTION > The curses trace routines are used for debugging the ncurses > libraries, > as well as applications which use the ncurses libraries. Some > limita‐ > tions apply: > > • Aside from curses_trace, the other functions are normally > available > only with the debugging library e.g., libncurses_g.a. > > All of the trace functions may be compiled into any model > (shared, > static, profile) by defining the symbol TRACE. > > • Additionally, the functions which use cchar_t are only > available > with the wide-character configuration of the libraries. > > ...and "normally available" should tell you that it's probably not > available > for your configuration unless you did something such as recompile. > > I did this to allow developers to substitute a debugging version, e.g., > using > LD_LIBRARY_PATH (which works well enough except for MacOS...). If the > entrypoint were only available when it's fully functional, that wouldn't > be useful for this case. > > Your application can check the return value to see if it was available: > > The curses_trace function is always available, whether or not the > other > trace functions are available: > > • If tracing is available, calling curses_trace with a nonzero > para‐ > meter updates the trace mask, and returns the previous trace > mask. > > When the trace mask is nonzero, ncurses creates the file > “trace” in > the current directory for output. If the file already > exists, no > tracing is done. > > • If tracing is not available, curses_trace returns zero (0). > > > And `curses_trace(TRACE_MAXIMUM)` seems to return 0 even when tracing is > > available and writing to a file called "trace" works. > > Probably because the previous bitmask was 0. > > yes :-) > > > But how do you check if tracing is available? > > call the function twice: > > curses_trace(TRACE_MAXIMUM); > rc = trace(TRACE_NORMAL); > > curs_set and umask do something like that with return-codes. > > -- > Thomas E. Dickey <[email protected]> > https://invisible-island.net >