[fpc-pascal]Forward type declaration

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Wed Apr 23 22:10:15 CEST 2003

On 23 Apr 2003, Johann Glaser wrote:

> Hi!
> Currently I'm translating libusb for FPC. Therefore I used "h2pas".
> libusb has two types called usb_device and usb_bus. Both are records.
> Each of them has fields, which have ^usb_device and ^usb_bus as types.
> So there is a cross type reference between these two records.
> In C they simply build a forward type declaration ("struct usb_device;
> struct usb_bus;"). In FPC unfortunately this is not possible. Is this
> correct?
> Are there any plans to add forward type declarations?

You can simply solve this by declaring
  Pusb_device = ^usb_device;
  usb_device = record

In fact, using the -P option of h2pas will do this for you.

> BTW: h2pas crashes with runtime error 216 when it encounters incomplete
> type definitions like the above mentioned "struct"s. I'm using the
> Debian 1.0.6-1 package of fp-compiler and all other parts.

This is a known problem; h2pas is far from perfect, it is meant to help
people out when translating by doing most of the work. Some things, however
cannot be done.


More information about the fpc-pascal mailing list