Hi Hansi... hope this code can help u!! 
(all with in the same "type" block... i.e. do not "interrupt" the "type" block with "const" or "procedure" or "function" or "type")
 
type
pusb_device  = ^usb_device;
pusb_bus = ^usb_bus;
 
// .. more typedefs
 
usb_device  = record
    a: pusb_bus;
    b: pusb_device;
    // x:  usb_device  is invalid (recursive!!!)
    // xx: usb_bus is invalid too.
    end;
 
// .. more typedefs
 
usb_bus = record
    c: pusb_bus;
    d: usb_device ;
    e: pusb_device ;
    // xx: usb_bus is invalid (recursive!!!)   
    end;
 
warm regards
max
 
Message: 1
From: Johann Glaser <[EMAIL PROTECTED]>
To: FPC-Pascal <[EMAIL PROTECTED]>
Organization:
Date: 23 Apr 2003 21:35:41 +0200
Subject: [fpc-pascal]Forward type declaration
Reply-To: [EMAIL PROTECTED]

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?

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.

Bye
  Hansi

Reply via email to