how to use ASSERT & TRACE macro in my Win32 Application project - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

how to use ASSERT & TRACE macro in my Win32 Application project

intint Posts: 22Member
must i add some head files

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : must i add some head files
    :

    Those are MFC macros. But assert.h has the assert() function.
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [b][red]This message was edited by AsmGuru62 at 2003-7-17 6:57:11[/red][/b][hr]
    : : must i add some head files
    : :
    :
    : Those are MFC macros. But assert.h has the assert() function.
    :
    [blue]This is an MFC board, but still: in pure Win32 you should include the "CrtDbg.h" and use the _ASSERT() (notice the underscore). There is no TRACE(), but it can be easily coded:[/blue][code]
    // ------------------------------------------------------------
    // [TRACE.CPP]
    // ------------------------------------------------------------
    char glb_TraceTxtBuf [256];

    // ------------------------------------------------------------
    // [TRACE.H]
    // ------------------------------------------------------------
    #include

    extern char glb_TraceTxtBuf [256];

    #ifdef _DEBUG
    #define TRACE(txt) OutputDebugString (txt)

    #define TRACE1(fmt,parm1)
    { sprintf (glb_TraceTxtBuf, fmt, parm1);
    OutputDebugString (glb_TraceTxtBuf); }

    #define TRACE2(fmt,parm1,parm2)
    { sprintf (glb_TraceTxtBuf, fmt, parm1, parm2);
    OutputDebugString (glb_TraceTxtBuf); }
    #else
    #define TRACE(txt) ((void)0)
    #define TRACE1(fmt,parm1) ((void)0)
    #define TRACE2(fmt,parm1,parm2) ((void)0)
    #endif // _DEBUG
    [/code]


Sign In or Register to comment.