Technical information

AN2216/D
CodeWarrior Compiler
MOTOROLA MC9S12DP256 Software Development Using Metrowerk’s Codewarrior 5
segment until the next #pragma CODE_SEG statement is encountered. Thus
assignment of the default segment is a convenient means of terminating a
specific segment:
#pragma CODE_SEG DEFAULT
A function prototype must be declared in the same code segment as the
function definition itself. Thus, if the function prototypes are declared in a
separate header file, the #pragma CODE_SEG statement must be duplicated,
as shown in Figure 2 and Figure 3.
#pragma CODE_SEG FUNCTIONS
void func1(void);
void func2(void);
#pragma CODE_SEG DEFAULT
Figure 2. Example header file functions.h
#include "functions.h"
#pragma CODE_SEG FUNCTIONS
void func1(void)
{
/* code */
};
void func2(void)
{
/* code */
};
#pragma CODE_SEG DEFAULT
Figure 3. Example Code with include file
It is recommended not to omit the #pragma CODE_SEG DEFAULT statement
at the end of the functions.h file, as the resulting behaviour will very much
depend on the use of #pragma CODE_SEG statements in other included files
and on the order in which such files are included.