when i compile:
program t(input,output); type s1=string(10); var s:s1; begin readln(s); writeln(substr(s,2,3)); end.
with gpc on solaris or linux, it compiles fine. when i compile with emxgpc, i get:
... ld -o t.exe /emx/lib/crt0.o -L/emx/lib/st -L/emx/lib C:\DOS\cce00002 -lgpc -lgcc -lc -lc_app -lc -lgcc -lemx -los2 -lemx2 rts-string.c:144 (/emx/lib/gpc.a(rts-string.o)): Undefined symbol ___gcc_bcmp referenced from text segment rts-string.c:188 (/emx/lib/gpc.a(rts-string.o)): Undefined symbol ___gcc_bcmp referenced from text segment rts-string.c:190 (/emx/lib/gpc.a(rts-string.o)): Undefined symbol ___gcc_bcmp referenced from text segment
am i using the wrong emx package? (other things compile fine..just problems working with strings) where can i get libs compatible with the latest emxgpc?
-- Thomas Dunbar 540 231-3938 (fax 3714) http://gserver.grads.vt.edu/
Hello Thomas Dunbar, hello GPC-list!
I can reproduce your error concerning strings with GPC for EMX:
when i compile:
program t(input,output); type s1=string(10); var s:s1; begin readln(s); writeln(substr(s,2,3)); end.
with gpc on solaris or linux, it compiles fine. when i compile with emxgpc, i get:
... (error messages)
The error comes from a wrong cooperation between GPC and GCC: Each of both thinks that it is job of the other one to implement the function __gcc_bcmp. Perhaps a recompile of GPC for EMX would solve the problem, but here is how you can get around the error: Just write a small file gcc_bcmp.c which contains the following:
/* __gcc_bcmp function */
/* Like bcmp except the sign is meaningful. Result is negative if S1 is less than S2, positive if S1 is greater, 0 if S1 and S2 are equal. */
typedef int size_t;
int __gcc_bcmp (s1, s2, size) unsigned char *s1, *s2; size_t size; { while (size > 0) { unsigned char c1 = *s1++, c2 = *s2++; if (c1 != c2) return c1 - c2; size--; } return 0; }
(I found it in the file libgcc2.c from the gcc-2.6.3 source.) Include it into the compile, e.g.:
gpc myfile.pas gcc_bcmp.c
A more elegant way would be to include the missing routine into gpc.lib for EMX. (But I don't know how to do this :-).
This problem will probably be fixed in my next release of GPC-EMX binaries.
Yours,
Peter
-------------------------------------------------------------------------------- Dipl. Phys. Peter Gerwinski Fachbereich Physik Universitaet-GH Essen Phone: +49-201-183-2763 D-45117 Essen Fax: +49-201-183-2120 Germany e-mail: pege@mail.theo-phys.uni-essen.de --------------------------------------------------------------------------------
Peter Gerwinski wrote:
Hello Thomas Dunbar, hello GPC-list!
I can reproduce your error concerning strings with GPC for EMX:
when i compile:
program t(input,output); type s1=string(10); var s:s1; begin readln(s); writeln(substr(s,2,3)); end.
with gpc on solaris or linux, it compiles fine. when i compile with emxgpc, i get:
... (error messages)
The error comes from a wrong cooperation between GPC and GCC: Each of both thinks that it is job of the other one to implement the function __gcc_bcmp. Perhaps a recompile of GPC for EMX would solve the problem, but here is how you can get around the error: Just write a small file gcc_bcmp.c which contains the following:
/* __gcc_bcmp function */
/* Like bcmp except the sign is meaningful. Result is negative if S1 is less than S2, positive if S1 is greater, 0 if S1 and S2 are equal. */
typedef int size_t;
int __gcc_bcmp (s1, s2, size) unsigned char *s1, *s2; size_t size; { while (size > 0) { unsigned char c1 = *s1++, c2 = *s2++; if (c1 != c2) return c1 - c2; size--; } return 0; }
thanks, that works (once i downloaded the dos gcc stuff)
so for now, i'm just having my students (high school pascal course) use:
gpc t.pas bcmp.o
(they're using 4meg boxes with little free disk space :( not even room for gcc, really. what i'd really like is to have them run linux but that would be _too_ much and not enough disk free anyway...)
but iguess now's as good a time as any to show them some C code, too.
(I found it in the file libgcc2.c from the gcc-2.6.3 source.) Include it into the compile, e.g.:
gpc myfile.pas gcc_bcmp.c
A more elegant way would be to include the missing routine into gpc.lib for EMX. (But I don't know how to do this :-).
This problem will probably be fixed in my next release of GPC-EMX binaries.
thanks, thomas
Yours,
Peter
Dipl. Phys. Peter Gerwinski Fachbereich Physik Universitaet-GH Essen Phone: +49-201-183-2763 D-45117 Essen Fax: +49-201-183-2120 Germany e-mail: pege@mail.theo-phys.uni-essen.de
can one convert a string of length one into a char?
ie the below wont work:
program t(input,output); var ch:char; s:string(10); begin s:='teststring'; writeln(substr(s,2,1)); ch:=substr(s,2,1); writeln(ord(ch)); end.
so, if one needs to get the ascii value of a particular value in a string, does one have to fall back to the std pascal of using packed array of char?
thomas
Hello, Thomas; hello, GPC-list!
According to Thomas Dunbar:
can one convert a string of length one into a char?
ie the below wont work:
program t(input,output); var ch:char; s:string(10); begin s:='teststring'; writeln(substr(s,2,1)); ch:=substr(s,2,1); writeln(ord(ch)); end.
Yes, one can. The correct assignment reads
ch:= s [ 2 ];
I think, this is Standard Pascal, nothing special. At least, it is common between UCSD, Borland and GNU Pascal.
In the above sense, a string actually *is* a packed array of char.
Yours,
Peter
-------------------------------------------------------------------------------- Dipl. Phys. Peter Gerwinski Fachbereich Physik Universitaet-GH Essen Phone: +49-201-183-2763 D-45117 Essen Fax: +49-201-183-2120 Germany e-mail: pege@mail.theo-phys.uni-essen.de --------------------------------------------------------------------------------
Peter Gerwinski wrote:
Hello, Thomas; hello, GPC-list!
According to Thomas Dunbar:
can one convert a string of length one into a char?
ie the below wont work:
program t(input,output); var ch:char; s:string(10); begin s:='teststring'; writeln(substr(s,2,1)); ch:=substr(s,2,1); writeln(ord(ch)); end.
Yes, one can. The correct assignment reads
ch:= s [ 2 ];
thanks, Peter.
i also find that readstr(substr(s,2,1),ch); works but the packed array way is simpler.
thomas
I think, this is Standard Pascal, nothing special. At least, it is common between UCSD, Borland and GNU Pascal.
In the above sense, a string actually *is* a packed array of char.
Yours,
Peter
Dipl. Phys. Peter Gerwinski Fachbereich Physik Universitaet-GH Essen Phone: +49-201-183-2763 D-45117 Essen Fax: +49-201-183-2120 Germany e-mail: pege@mail.theo-phys.uni-essen.de