[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?
From: |
gouy yann |
Subject: |
Re: [avr-gcc-list] Initilizing complex const arrays : syntax ? |
Date: |
Sun, 18 Sep 2005 20:26:57 +0200 (CEST) |
Hi all,
Vince, my corrections are in your code, go down and see!!
the problem is, somehow, you double instantiate your structure.
regards
Yann
--- Vincent Trouilliez <address@hidden> a écrit :
> Thanks guys for the help,
>
>
> I appear to have one last little problem about this :
>
> if I do as David did, that is declare my array in main.c, then it works
> fine. If I declare the array in ui.h ("ui" stands for User Interface in
> my case), and include ui.h in main.c, then it's good too. However if I
> do as intended, that is, create an ui.c file which will contain
> functions that make use of the array defined in ui.h, well.....in this
> case main.c and ui.c compile fine, but the linker will fail sadly :-/
>
> $make
> avr-gcc -O -g -Wall -ffreestanding -mmcu=atmega32 -c main.c
> avr-gcc -O -g -Wall -ffreestanding -mmcu=atmega32 -c ui.c
> avr-gcc -o object.elf -O -g -Wall -ffreestanding -mmcu=atmega32
> -Wl,-Map,object.elf.map -Wl,--section-start=.eeprom=00810001 main.o ui.o
> ui.o(.progmem.data+0x0): multiple definition of `param_list'
> main.o(.progmem.data+0x0): ~/avr/Projects/test2/main.c:3: first defined
> here
> make: *** [object.elf] Error 1
>
>
> I can't make sense of the error messages.
> I did notice that it does link fine, if I comment out the "include
> ui.h" in ui.c, but you just all taught me the other day to always
> include foo.h at the top of foo.c, when writing a module, which makes
> sense since modules are compiled independently so need their .h file to
> be complete. So I am lost again...
>
>
> Regards,
>
>
> --
> Vince
>
>
>
> The complete test program is as follows, can't make it simpler :
>
>
> main.c
> ------
>
> #include "ui.h"
>
> void main (void){
>
> }
>
> ui.c
> ----
> #include "ui.h"
// your structure instatiation
const struct param __ATTR_PROGMEM__ param_list[] = {
{ "Throttle", " %", "%2d" },
{ "Eng. Speed", "RPM", "%4d" },
{ "M. A. T.", " °C", "%2d" },
{ "M. A. P.", "Bar", "3.2f"}
};
>
>
> ui.h
> ----
>
> #include <avr/pgmspace.h>
>
> //data type for one engine parameter
> struct param {
> char desc[11];
> char unit[4];
> char format[6];
> };
>
>
// your structure declaration
extern const struct param __ATTR_PROGMEM__ param_list[];
>
>
>
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com
- [avr-gcc-list] Initilizing complex const arrays : syntax ?, Vincent Trouilliez, 2005/09/17
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Royce Pereira, 2005/09/17
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Jesper Hansen, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Anton Erasmus, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Jesper Hansen, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Anton Erasmus, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Vincent Trouilliez, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Jesper Hansen, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, David Kelly, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Vincent Trouilliez, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Vincent Trouilliez, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Richard Urwin, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Vincent Trouilliez, 2005/09/18