07.04.2013 Views

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16-Bit C <strong>Compiler</strong> User’s Guide<br />

3.5.5 Options <strong>for</strong> Debugging<br />

The following options are used <strong>for</strong> debugging.<br />

TABLE 3-7: DEBUGGING OPTIONS<br />

Option Definition<br />

-g Produce debugging in<strong>for</strong>mation.<br />

The compiler supports the use of -g with -O making it possible<br />

to debug optimized code. The shortcuts taken by optimized code<br />

may occasionally produce surprising results:<br />

• Some declared variables may not exist at all;<br />

• Flow of control may briefly move unexpectedly;<br />

• Some statements may not be executed because they<br />

compute constant results or their values were already at<br />

h<strong>and</strong>;<br />

• Some statements may execute in different places because<br />

they were moved out of loops.<br />

Nevertheless it proves possible to debug optimized output. This<br />

makes it reasonable to use the optimizer <strong>for</strong> programs that might<br />

have bugs.<br />

-Q Makes the compiler print out each function name as it is<br />

compiled, <strong>and</strong> print some statistics about each pass when it<br />

finishes.<br />

-save-temps Don’t delete intermediate files. Place them in the current directory<br />

<strong>and</strong> name them based on the source file. Thus, compiling<br />

foo.c with -c -save-temps would produce the following<br />

files:<br />

foo.i (preprocessed file)<br />

foo.p (pre procedure abstraction assembly language file)<br />

foo.s (assembly language file)<br />

foo.o (object file)<br />

3.5.6 Options <strong>for</strong> Controlling Optimization<br />

The following options control compiler optimizations.<br />

TABLE 3-8: GENERAL OPTIMIZATION OPTIONS<br />

Option Definition<br />

-O0 Do not optimize. (This is the default.)<br />

Without -O, the compiler’s goal is to reduce the cost of compilation<br />

<strong>and</strong> to make debugging produce the expected results.<br />

Statements are independent: if you stop the program with a<br />

breakpoint between statements, you can then assign a new<br />

value to any variable or change the program counter to any<br />

other statement in the function <strong>and</strong> get exactly the results you<br />

would expect from the source code.<br />

The compiler only allocates variables declared register in<br />

registers.<br />

-O<br />

-O1<br />

Optimize. Optimizing compilation takes somewhat longer, <strong>and</strong><br />

a lot more host memory <strong>for</strong> a large function.<br />

With -O, the compiler tries to reduce code size <strong>and</strong> execution<br />

time.<br />

When -O is specified, the compiler turns on<br />

-fthread-jumps <strong>and</strong><br />

-fdefer-pop. The compiler turns on<br />

-fomit-frame-pointer.<br />

DS51284H-page 46 © 2008 <strong>Microchip</strong> Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!