DEBUG statements--what are they??

This is a discussion on DEBUG statements--what are they?? within the C++ Programming forums, part of the General Programming Boards category; Hi, I have a question about DEBUG statements. I am not sure how they work. I keep seeing #ifdef DEBUG ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    DEBUG statements--what are they??

    Hi,

    I have a question about DEBUG statements. I am not sure how they work.

    I keep seeing #ifdef DEBUG

    --some code--

    #endif

    Could someone please give an example or maybe a good site where I can understand how DEBUG statements work and what they are for??

    Thanks a lot for the help!

  2. #2
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    It's actually not a statement, it's a preprocessor define.

    If DEBUG is defined, the code between if and endif will be compiled. So it's a way to enable or disable parts of your program at compiletime.

    I assume in your case, the code between if and endif somehow helps the coder to find bugs in the code. Since it would also probably slow down the application, this additional, otherwise unneccessary code can be disabled by not defining DEBUG.

    You can define a preprocessor value like

    #define somename somevalue

    somevalue is optional

    or undefine it with

    #undef somename


    Check this link.
    Last edited by darksaidin; 08-29-2003 at 11:15 AM.
    [code]

    your code here....

    [/code]

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    thanks - another question

    thanks---I have another ?

    between the #ifdef DEBUG and #endif there are cout debugging statements.

    I want to see these statements...

    I ran the program and got a.out, but not sure how to be able to execute the line b/w the #ifdef DEBUG and #endif.

    I tried doing a.out DEBUG, but this didn't work??

    How would I be able to do that??

    Thanks for the help!

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    just figured it out--

    thanks anyway....I just figured it out...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary not built with debug info - why?
    By ulillillia in forum C Programming
    Replies: 15
    Last Post: 12-11-2008, 01:37 AM
  2. makefiles - debug & release?
    By cpjust in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 05:00 PM
  3. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 12:08 PM
  4. Good practice of writing debug print statements
    By hzmonte in forum C Programming
    Replies: 11
    Last Post: 11-09-2005, 11:55 PM
  5. Ask about Debug Assert Failed
    By ooosawaddee3 in forum C++ Programming
    Replies: 0
    Last Post: 04-25-2002, 12:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21