Skip to Main Content
C++ Cookbook
book

C++ Cookbook

by D. Ryan Stephens, Christopher Diggins, Jonathan Turkanis, Jeff Cogswell
November 2005
Beginner to intermediate content levelBeginner to intermediate
594 pages
16h 23m
English
O'Reilly Media, Inc.
Content preview from C++ Cookbook

1.21. Producing a Debug Build

Problem

You want to build a version of your project that will be easy to debug.

Solution

In general, to produce a debug build, you must;

  • Disable optimizations

  • Disable expansion of inline function

  • Enable generation of debugging information

Table 1-20 presents the compiler and linker options to disable optimization and inlining; Table 1-21 presents the compiler and linker options to enable debugging information.

Table 1-20. Disabling optimization and inlining from the command line

Toolset

Optimization

Inlining

GCC

-O0

-fno-inline [12]

Visual C++Intel (Windows)

-Od

-Ob0

Intel (Linux)

-O0

-Ob0

-opt off

-inline off

Comeau (Unix)

-O0

--no_inlining

Comeau (Windows)

Same as backend, but using a slash (/) instead of a dash (-)

Borland

-Od

-vi-

Digital Mars

-o+none -S

-C

[12] It’s not necessary to specify this option unless -O3 has also been specified.

Table 1-21. Command-line options for enabling debug information

Toolset

Compiler options

Linker options

Comeau (Unix) GCCIntel (Linux)Metrowerks

-g

-g

Visual C++Intel (Windows)

See Table 1-22.

See Table 1-22.

Comeau (Windows)

Same as backend, but using a slash (/) instead of a dash (-).

Same as backend compiler option, but using a slash (/) instead of a dash (-).

Borland

-v

-v

Digital Mars

-g

-co

Table 1-22. Enabling debugging information with Visual C++ or Intel for Windows

Compiler options

Linker options

IDE options[13]

Description ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ System Programming Cookbook

C++ System Programming Cookbook

Onorato Vaticone

Publisher Resources

ISBN: 0596007612Supplemental ContentErrata Page