I ported some code to gpc 2.0, i make the test in home with a linux rh 5.2, whit this piece of code, all works fine: program test; procedure test( s: string); begin writeln('String:',s); end; begin test('Esto es de prueba'); end. But when i put the procedure prueba in a unit, it crash: <<modulo.p>> unit modulo; interface procedure prueba( s: string); implementation procedure prueba( s: string); begin writeln('Cadena:',s); end; end. <<prueba.p>> program Prueba; uses modulo; begin prueba('Esto es de prueba'); end. And this is the output: Cadena:E Segmentation fault (core dumped) And this with xxgdb: (xxgdb) list modulo.p:1 (xxgdb) tbreak 11 Breakpoint 1 at 0x8048d93: file modulo.p, line 11. (xxgdb) run Prueba (S={Capacity = 0, length = 17, string = 0xbffffd88}) at modulo.p:11 The diference is te Capacity = 0, with the first code its run fine??? What can i do???? I need this work in gpc 2.0 because is the compiler that have the machine, in that i must drop the practics
Hi, "root", better use a user account to write your email. That's safer and does not irritate your recipients. root wrote:
I ported some code to gpc 2.0, i make the test in home with a linux rh 5.2, whit this piece of code, all works fine: [...] But when i put the procedure prueba in a unit, it crash: [...] Prueba (S={Capacity = 0, length = 17, string = 0xbffffd88}) at
This is another known bug in gpc-2.0: String variables in units (or modules) are not initialised correctly.
What can i do????
While the best thing would still be to upgrade to gpc-19990118, you can try to work around that bug and initialise the string manually in the "to begin do" part of your module: Type pInteger = ^Integer; to begin do pInteger ( @MyString )^ := MyCapacity; with `MyCapacity' being the declared capacity of the variable `MyString'.
I need this work in gpc 2.0 because is the compiler that have the machine, in that i must drop the practics
In principle you can cross-compile from your home machine to the machine the code has to run on, but I can imagine that this is not the demanded thing ... :-( Good luck, Peter -- Peter Gerwinski, Essen, Germany, http://home.pages.de/~Peter.Gerwinski/ Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - gpc-19990118 PGP key on request - 6C 94 45 BE 28 A4 96 - 0E CC E9 12 47 25 82 75 *** Vote against SPAM! ********* http://www.politik-digital.de/spam/ ***
participants (2)
-
Peter Gerwinski -
root