SW006012 Microchip Technology, SW006012 Datasheet - Page 25

C COMPILER FOR DSPIC30F FAMILY

SW006012

Manufacturer Part Number
SW006012
Description
C COMPILER FOR DSPIC30F FAMILY
Manufacturer
Microchip Technology
Type
MPLAB® C30 Compilerr
Series
PIC24 & DsPICr
Datasheets

Specifications of SW006012

Supported Families
PIC24, DsPIC30F And DsPIC33F
Core Architecture
PIC, DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Tool Type
Compiler
Processor Series
PIC24, dsPIC
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
dsPIC30F
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2007 Microchip Technology Inc.
Differences Between MPLAB C30 and ANSI C
The weak attribute may be applied to functions as well as variables:
extern int
int process(void *buf) {
}
In the above code, the function compress_data will be used only if it is linked in from
some other module. Deciding whether or not to use the feature becomes a link-time
decision, not a compile time decision.
The affect of the weak attribute on a definition is more complicated and requires
multiple files to describe:
Here the definition in weak2.c of i causes the symbol to become a strong definition.
No link error is emitted and both i’s refer to the same storage location. Storage is
allocated for weak1.c’s version of i, but this space is not accessible.
There is no check to ensure that both versions of i have the same type; changing i in
weak2.c to be of type float will still allow a link, but the behavior of function foo will
be unexpected. foo will write a value into the least significant portion of our 32-bit float
value. Conversely, changing the type of the weak definition of i in weak1.c to type
float may cause disastrous results. We will be writing a 32-bit floating point value into
a 16-bit integer allocation, overwriting any variable stored immediately after our i.
In the cases where only weak definitions exist, the linker will choose the storage of the
first such definition. The remaining definitions become in-accessible.
The behavior is identical, regardless of the type of the symbol; functions and variables
behave in the same manner.
if (compress_data) {
}
/* process buf */
/* weak1.c */
int
void foo() {
}
/* weak2.c */
int i;
extern void foo(void);
void bar() {
}
main() {
}
if (compress_data(buf) == -1) /* error */
i = 1;
i = 2;
foo();
bar();
__
attribute
__
attribute
__
((
__
__
((
weak
__
weak
__
)) i;
__
)) compress_data(void *buf);
DS51284F-page 19

Related parts for SW006012