Andrew Cameron wrote:
function getname: string; begin getname := 'somestring'; end; [...] I am using gpc version 2.0
Please upgrade to a more recent version such as gpc-19980830; see ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/beta/.
The error message comes from GPC's strings not being limited to a maximum of 255 chars. On a 32-bit platform, they can be up to 4GB long. For this reason, GPC cannot determine a reasonable default length for strings being returned as function results.
While gpc-19980830 will compile your program (defaulting to 255, with a warning), it is better to avoid the problem by something like this:
type mystring = string (255);
function getname: mystring; begin getname := 'somestring'; end;
Hope this helps,
Peter