[fpc-devel] Re: strange error with arm compiler when compiling-running this code
Roozbeh GHolizadeh
roozbehid at yahoo.com
Wed Mar 14 21:38:51 CET 2007
well i am really going crazy.these c codes run ok
-------------------testpchar.c-------------
typedef struct
{
char *name;
}
namestruct;
namestruct namestructs[1] =
{{"12345"}};
int findname (char *s)
{
return namestructs[0].name[1];
}
----------------main.c------------------
int main (int argc, char *argv[])
{
char s[]="s";
printf("start\n");
printf("%d \n",findname(s));
printf("end\n");
return 0;
}
output is :
start
50
end
and now the pascal code
{$apptype console}
{$link testpchar.o}
function findname (s : PChar) :
cardinal;cdecl;external name 'findname';
var
s:shortstring;
begin
writeln('start');
s:='s'#0#1;
writeln(findname(@s[1]));
writeln('end');
end.
output is
start
runtime error 216
and if i change the c code into
.
.
return namestructs[2].name[1];//ie change 0 into 2
.
.
output is
start
50
end
which is ok!
so whay exactly is wrong here,fpc compiler or evc compiler?!
____________________________________________________________________________________
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097
More information about the fpc-devel
mailing list