On Sun, 25 May 2003, Russell Whitaker wrote:
On Sat, 24 May 2003, Mirsad Todorovac wrote:
Hi, Frank!
------------------------------------------------------- program mirsad16(output);
function testproc (n: LongCard): String(64); begin n := n; return 'OK'; end;
begin WriteLN (testproc (42)); end. ------------------------------------------------------- bash-2.05b$ gpc -Wall mirsad16.pas mirsad16.pas:4: warning: missing string capacity -- assuming 255 mirsad16.pas:4: parse error before `('
I couldn't find in reference docs whether this is actually banned by specification, or is it a bug in parser.
I think it is a minor bug that's been around for quite some time.
This works with only the warning message:
function( n: Longcard ): String;
This works with no messages:
Type Astring = string( 123 ); function( n: Longcard ): Astring;
Incidently, since the function return is on the stack if you write Astring = string( 123456789 ); you will get a run time seg fault.
my 2 cents
That's been helpful. Thanks. There's another odity related to program in this example: --------------------------------------------------------------------- bash-2.05b$ more strconst.pas program strconst (output); var digits : String [35] value '0123456789abcdefghijklmnopqrstuvwxyz'; begin WriteLn ('digits = ', digits); end. ----------------------------------------------------------------------- bash-2.05b$ gpc strconst.pas strconst.pas:5: warning: string constant exceeds capacity -- truncated bash-2.05b$ When digits is set to String[36], only then the constant is not truncated. Is there some rule about this behavior, or should it be set even higher than Sizeof('0123456789abcdefghijklmnopqrstuvwxyz')+10 so it would be safe for all architectures? Thanks, Mirsad -- "I have a dream!" -- Martin Luther King Jr. "You can't hold someone down ... without staying down with him." -- Booker T. Washington