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 |
|
|
|
Visual C++Intel (Windows) |
|
|
|
Intel (Linux) |
|
|
|
|
| |
|
Comeau (Unix) |
|
|
|
Comeau (Windows) |
Same as backend, but using a slash (/) instead of a dash (-) | |
|
Borland |
|
|
|
Digital Mars |
|
|
[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 ... |
|---|