[fpc-pascal]Re: Forward type declaration

max martinelli max at cablenet.com.ar
Thu Apr 24 23:28:57 CEST 2003


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 <Johann.Glaser at gmx.at>
To: FPC-Pascal <fpc-pascal at deadlock.et.tudelft.nl>
Organization: 
Date: 23 Apr 2003 21:35:41 +0200
Subject: [fpc-pascal]Forward type declaration
Reply-To: fpc-pascal at lists.freepascal.org

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20030424/bce02720/attachment.html>


More information about the fpc-pascal mailing list