Hi,
please help me with SDCC compiler ver. 2.2.1. for Windows. I have two problems:
1. In module E248.C is function:
unsigned char E248WriteByte(...)
{
switch(...)
{
case(...):
{
 
unsigned char i; <-- here is problem
 
for(i=0;i<8;i++)
{ ... };
return(...);
};
case(...):
{
 
unsigned char i; <-- here is problem
 
for(i=0;i<8;i++)
{ ... };
return(...);
};
case(...):
{ ...;return(...);};
default:
{ ...;return(...);};
}
and I import E248.h to main.c. When I compile E248.c:
sdcc.exe --model-small --stack-after-data -L ... -I ... -c e248.c
the compiler report:
e248.c(115): warning *** 'auto' variable 'i' may be used before initialization at e248.c(91),
and when I compiled main.c:
sdcc.exe --model-small --stack-after-data -L ... -I ... -c main.c e248.rel
the compiler report:
?ASLink-Warning-Undefined Global '_E248WriteByte_1_3_5' referenced by module 'e248'
 
I don't know why, I think it is correct in ANSI C.
 
2. In the same module (E248.c) I have functions:
unsigned char ReadByte(...,unsigned char *value)
{
...
*value=...;
return(...);
}
unsigned char WriteByte(...,unsigned char value)
{
...
array[i]=value;
return(...);
}
When I call this functions from main, like this:
void main(void)
{
unsigned char a;
...
ReadByte(..., &a);
WriteByte(..., a);
ReadByte(..., &a);
WriteByte(..., a);
ReadByte(..., &a);
WriteByte(..., a);
}
reading "a" occurs only in the first call and to every write is used this "a".
I think it is problem of optimalization, when I insert between "write" and next "read" for example "a=0;", it's correct.
Is any way to resolve this problem deterministicly.
I'm afraid that this problem turns up sometimes a I will not find it.
Thank you very much for your answers.
Petr Chmelar
 
petr.chmelar@vsb.cz  (preffered) or
petr.chmelar@sendme.cz
P.S. Excuse my English, please.