Thread: g++ debug/release mode

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    19

    g++ debug/release mode

    hello,

    is there something like a debug/release mode in g++ like in ms visual studio 2003?

    regards,

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Historically, the microsoft debugger could not handle optimised code, so either you had a debug build (lots of debug, no optimisation), or release (no debug, optimised code). I don't know if the latest versions solve this problem.

    The GNU tools allow the debugger to work with optimised code, although the results can look pretty odd if you're single-stepping through optimised code

    Basically, all it means for you is that "release" adds "-O2" to the compiler command line. The 2 is the level of optimisation (there are several more as described in the manual).
    There are also a huge number of long options to request specific optimisations to be carried out when you want more control than the summary options like -O2 provide.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    also, use -g to include debug info in your build. This will help when using tools like gdb.

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    19
    And when I compile code with "g++ -O2" on my XEON machine, is it already optimized for the processor?

  5. #5
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    yes.

    whenever you build with optimisations it is optimised for the processor.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    84
    what about defining NDEBUG to disable assert and other debug macros?
    any others define symbols to control debugging?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shortening main
    By pdstatha in forum C Programming
    Replies: 1
    Last Post: 04-03-2002, 04:56 PM
  2. Showing the directory sturcture
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 03-26-2002, 04:46 PM
  3. Implementing "ls -al"
    By pdstatha in forum Linux Programming
    Replies: 11
    Last Post: 03-20-2002, 04:39 AM
  4. free() usage
    By pdstatha in forum C Programming
    Replies: 5
    Last Post: 03-13-2002, 09:28 AM
  5. Implementing "ls -al"
    By pdstatha in forum C Programming
    Replies: 7
    Last Post: 03-06-2002, 05:36 PM