[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] global variables
From: |
Tomas Krcka |
Subject: |
[avr-gcc-list] global variables |
Date: |
Fri, 19 Aug 2005 10:27:30 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
Hi!
I have a problem with global variables in my project.
The problem is:
I have file system.c
byte proc_tbl[MAX_PROCESS]; //it's global variable in system.c
void System_Init(void){
int i;
for (i = 0;i < MAX_PROCESS; i++)
proc_tbl[i] = NOT_USED;
}
and function
byte Create_Process(void){
int i;
for (i=0; i < MAX_PROCESS; i++)
if (proc_tbl[i] == NOT_USED){
proc_tbl[i] = USED;
return(OK);
}
return(ERROR);
}
It's a simplified example, but doesn't work too.
If I call these functions in main.c
System_Init();
Create_Process();
function Create_Process return ERROR permanently.
If global variable proc_tbl is static, it's work fine.
And If I change sequence of linking obj files, system.o is first, It's
work fine too.
Compiling and linking : example for all files
main.o : main.c
$(CC) $(CFLAGS) -Os -c main.c
main.out: main.o all obj files
$(CC) $(CFLAGS) -o main.out main.o all obj files
main_eeprom.hex: main.out
$(OBJCOPY) -j .eeprom -O ihex main.out main_eeprom.hex
main_flash.hex: main.out
$(OBJCOPY) -R .eeprom -O ihex main.out main_flash.hex
I don't know what's wrong. Maybe some error with memory.
Do you have ideas?
Thanks.
Tom
- [avr-gcc-list] global variables,
Tomas Krcka <=