[fpc-pascal] type definitions etc

Hans Maartensson cirkulation at maartensson.net
Thu May 26 14:06:48 CEST 2005

For quite some time I have been using FreePascal for occasional programming 
(windows programs); it works fine, so I don't post so many stupid questions 
to this list any more.

But now I have downloaded the new version 2, driven by the enthusiasm in 
the announcement, and trying to compile some of my old programs with the 
new version rose a few questions.

In a program I had a recursive definition like:

type sometype = record
   n: longint;
   p: ^sometype

This worked in version 1.0, but in version 2.0 the compiler complains that 
the type is not fully defined. Is there a good reason why that is not 
allowed any more.? It was practical for making chains of data structures.

Also the following call to a win32 API function is not allowed any more:

invalidaterect(windows, 0, true);

The error is that the 2nd parameter should be of type 'rect'.
I know that careful type checking is a fundamental part of pascal 
philosophy, and this is good for preventing many programming errors. But on 
the other hand some windows API functions make use of the rule that 
substituting null for some type makes the function use a default value.
Is there a general way to get around this problem?
The 2nd parameter in this example must be of 'var' type, which means that 
it is the pointer to the parameter that is transferred to the function. 
Transferring a nil pointer is in pascal language the same as leaving the 
parameter undefined. But that is not possible in FreePascal, is it?

With the installation of version 2, I had the problem that the figures are 
missing from the html-documentation.
I downloaded the zipped file from the special link and unpacked it to 
D:\FPC\2.0.0\ and it went into the already existing doc directory. But some 
(or may be all) of the figures are missing from the text.

Finally I would like to ask about the following.
The compiler does not allow a procedure definition like:

procedure someproc(p: ^double);

whereas the following is perfectly possible:

type Tpdouble = ^double;
procedure f(p: Tpdouble);

Is there a good reason for this? Why isn't  ^double a valid type everywhere?

Hans Maartensson

More information about the fpc-pascal mailing list