Thread: Debugging mode selection during compile time

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    7

    Question Debugging mode selection during compile time

    Is that possible to set the Debugging mode in compiltime by setting the some preprocessor variables or so.

    In Linux or in Unix when i compile i should be able to give a -<character> so that my program start compiling in the debugging mode. I that Possible.

    For ex.

    If i give as gcc -D <program name> or so then the program should start compiling in debugging mode.


    Please give ur valubles suggessions.

  2. #2
    alex
    Guest
    I'm not sure what you are asking... Maybe...

    let's assume you have the following code (prog.c)
    Code:
    #include <stdio.h>
    
    main()
    {
    #ifdef DEBUG
       fprintf(stderr, "Debugging mode!\n");
    #endif
    }
    then the program compiled with "gcc -DDEBUG prog.c" will print the string, but compiled with the usual "gcc prog.c" won't.

    the option -Dstring1 behaves like "#define string1" at the start of the code, and -Dstring1=string2 is equivalent to "#define string1 string2".

    But all of this has nothing to do with debugging, just with including/excluding pieces of code, depending on a command line parameter. If you want to do "real" debugging, start with reading "man gdb" and "info gdb" (and compile with gcc -g prog.c).

    I hope I answered you question somehow...

    alex

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Compile time decision...
    By Roaring_Tiger in forum C Programming
    Replies: 2
    Last Post: 10-17-2004, 02:50 AM
  3. Military Time Functions
    By BB18 in forum C Programming
    Replies: 6
    Last Post: 10-10-2004, 01:57 PM
  4. inputting time in separate compilation
    By sameintheend01 in forum C++ Programming
    Replies: 6
    Last Post: 03-13-2003, 04:33 AM
  5. compile time errors!!!!
    By devour89 in forum C++ Programming
    Replies: 6
    Last Post: 11-18-2002, 05:02 PM