[fpc-devel] Re: strange error with arm compiler when compiling-running this code

Florian Klaempfl florian at freepascal.org
Wed Mar 14 21:57:09 CET 2007


Roozbeh GHolizadeh schrieb:
> well i am really going crazy.these c codes run ok


Use -Xe, this looks like a known bug of the elf linker with constant
data sections.

> -------------------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
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list