Hi Vijay,the first problem is a consequence of (as the linker says) multiple definitions: Definitions should never (!) be found in header files but rather in your .c files. Headers should only contain declarations (except macro definitions which is another part of the C language). The correct way to provide this is to change the definitions to extern declarations:
extern const __attribute__ ((section (".flashA"))) int SystemPrefix;
(...)
Subsequentially add the definition (without extern) of each of your
constants (as well as variables) to a certain .c file which is
guaranteed to be compiled and linked to the whole object.
To make the difference visible consider files a.h b.c and c.c in two cases: 1. File a.h contains definitions and 2. File a.h contains only declarations.
In both cases you would not compile the header file itself.In the first case b.c including a.h is compiled, the compiler finds the definition and generates a constant (memory area with a name symbol for address resolution) in file b.o. Then c.c including a.h is compiled, the compiler does the same as described above for c.o. In the end The linker finds two memory areas trying to reserve both of them in memory (which might be the meaning/reason for your final error message: The double amount of mem space is needed to store all of your constants). Finally it tries to resolve references in code to the names and does not know which of two different addresses with the identical names shall be inserted for this reference.
In the second case b.c including a.h is compiled, the compiler reads the extern declaration and thereby learns that an externally defined symbol of a certain type will exist and can be referenced. Later in b.c it finds a reference to that symbol and knows that this reference will be resolved at link time. Then c.c including a.h is compiled, the compiler learns the symbol the same way as before. It then finds the definition (without extern) in the c.c file itself, checks for corresponding types (with the declaration) and defines a memory area with its name. Later the linker (linking b.o and c.o) puts this defined memory area to an own address and uses this address for resolving the references from b.o and c.o.
Regards Arnd-Hendrik Vijay wrote:
hai guys,i have another error, when i am compiling i am getting the following error....Gsm.o(.flashA+0x6): In function `UartTaskComplete': /cygdrive/c/Documents and Settings/Desktop/latestOBDISODriver/Gsm.c:38: multiple definition of `OBDDY' Main.o(.flashA+0x6):/cygdrive/c/Documents and Settings/Desktop/latestOBD ISODriver/Main.c:38: first defined here Gsm.o(.flashA+0x5a): In function `GsmTimeout': /cygdrive/c/Documents and Settings/Desktop/latestOBDISODriver/Gsm.c:77: multiple definition of `IMEINumber' Main.o(.flashA+0x5a):/cygdrive/c/Documents and Settings/Desktop/latestOB DISODriver/Main.c:110: first defined here Gsm.o(.flashB+0x0): In function `UartTaskComplete': /cygdrive/c/Documents and Settings/Desktop/latestOBDISODriver/Gsm.c:37: multiple definition of `UserList' msp430-ld: region data is full (JL2 section .flashA) make: *** [JL2] Error 1thes e varibles, like UserList,IMEINumber etc.. are flash variables and i have declared it as follows in the header file:const __attribute__ ((section (".flashA"))) int SystemPrefix;const __attribute__ ((section (".flashA"))) struct OBDDynamicVariables OBDDY[2];const __attribute__ ((section (".flashA"))) struct OBDStaticVariables OBDST; const __attribute__ ((section (".flashA"))) unsigned int IMEINumber[8]; const __attribute__ ((section (".flashA"))) unsigned int MyPhoneNumber[8]; const __attribute__ ((section (".flashA"))) unsigned int UserPhoneNumber[8]; const __attribute__ ((section (".flashA"))) int SystemStatus ;i thought it might be becoz of multiple inclusion of header files,and i added#ifndef <filename> #define<filename> ........#endifin all the header file, but still i am having this probelm, i refrred to the compile folder(mspgcc)in my drive and had a look in the ir include files , and did the same thing...of how they have included to avoid this ..still i am helpless!! could any one suggest me ,to overcome this error,thank you vijay __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
