On Wed, 19 Jul 2006, Bastiaan Veelo wrote:
Adriaan van Os wrote:
Markus Gerwinski wrote:
Bastiaan Veelo wrote:
type record_with_empty_string = record empty_string : string(127) {VALUE ''}; end;
This program compiles. But if you uncomment the initial value of empty_string, GPC complains with "initial value of discriminated schema type is of wrong type". Things like this used to work with Prospero.
Is there a workaround?
Your program builds and runs fine in my environment. What version of gcc and gpc are you using?
I'm running the gpc-20050331 snapshot based on gcc-3.4.3.
No problems here either, with gpc version 20051116, based on gcc-3.4.5 on I386-apple-darwin.
Regards,
Adriaan van Os
My version is gpc 20051116, based on gcc-3.2.3 (mingw special 20030504-1). Indeed, the program compiles. The problem begins after uncommenting the initial value. Sorry for the confusion :-) For completeness here follows the code that _does not_ compile as is.
program stringtest;
type record_with_empty_string = record empty_string : string(127) VALUE ''; end; some_records_with_empty_string(length : integer) = array[1..length] of record_with_empty_string; five_records_with_empty_string = some_records_with_empty_string(5);
begin end.
tried it - got error message: stringtest.pas:9: error: initial value of discriminated schema type is of wrong type
line 9 is the "five_records ..."
I suspect that without the "VALUE" when the compiler allocates space for a string both the capacity and length fields are initialized, in this case 127 and 0. Frank or Waldek would know for sure.
A nice safe workaround is to initialize your strings with a for-loop.
russ