g++ debug/release mode

This is a discussion on g++ debug/release mode within the Linux Programming forums, part of the Platform Specific Boards category; hello, is there something like a debug/release mode in g++ like in ms visual studio 2003? regards,...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

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