CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Is it possible to do macro...

    I want to do 2 macros... the first one will be called:

    #define BEGIN_DEBUG

    and the second will be called:

    #define END_DEBUG

    The goal is when i'm in debugging mode i want be abl to do things like that:


    BEGIN_DEBUG
    {
    // Some c++ code...
    }
    END_DEBUG

    But when i'm in release mode this block of code must disapears..

    Is this possible?
    If it is ... whats the trick?

    Tanks.

    Reply to : [email protected]


  2. #2

    Re: Is it possible to do macro...

    Two tricks:

    1). Use the _DEBUG macro that is already defined by the compiler:

    #ifdef _DEBUG
    DoVeryLongAndBoringTest();
    EvenMoreSlowDebugging();
    #endif

    2). If it's only going to take one line of code, do this:

    DEBUG_ONLY(AfxMessageBox("Got this far without crashing!"));

    HTH.

    LA Leonard - http://www.DefinitiveSolutions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured