This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Windows TRACE message


Rui-Tao Dong <rdong@newport.com> writes:
> 
> >>>>> "Mumit" == Mumit Khan <khan@xraylith.wisc.EDU> writes:
> 
>  >> Is there a way to re-direct windows TRACE message to stderr under
>  >> cygwin?
>  >> 
> 
>  Mumit> What're windows TRACE messages?
> 
> I mean messages shows up in VC studio's message window (produced by
> TRACE macro?).
> 

TRACE is not part of Win32 API, but rather part of MFC. However, it
looks like it's a "printf" style interface, so for a console-mode
program, a trivial implementation may look like the following:

  #include <stdio.h>

  #define TRACE printf
  int
  main ()
  {
    TRACE ("Entering %s\n", __PRETTY_FUNCTION__);
    TRACE ("Leaving %s\n", __PRETTY_FUNCTION__);
    return 0;
  }


$ gcc -o foo-test foo-test.c
$ ./foo-test
Entering main
Leaving main

Of course, a reasonable implementation would something much more complicated
to avoid code and runtime overhead when TRACE is turned off.

Hint: define TRACE in terms of a function taking variable number of
arguments and there use ANSI vfprintf routine to do the printing if
tracing is enabled or just return.

A win32 implementation should also check if it's GUI app; if so, open
a new console (AllocConsole and so on) and write to the new console
(or open a window with a text widget and send text to it).

Feel free to innovate. It really isn't a Cygwin issue of course.

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]