Re: [fpc-pascal]Apple Mac pointer problem

2004-09-24 Thread Jonas Maebe
On 24 sep 2004, at 03:33, Harald Houppermans wrote:
But my first posting was correct... it's a pointer to a pointer to 
data.

Are you sure you want that ?
Probably, yes. A pointer to a pointer to data is called a handle under 
classic Mac OS, and was used a lot there (so the OS could defragment 
the heap without the need for a virtual memory subsystem).

Jonas
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


RE: [fpc-pascal]Apple Mac pointer problem

2004-09-24 Thread Stephen Downs


> -Original Message-
> From: Olle Raab [mailto:[EMAIL PROTECTED]
> Sent: 23 September 2004 21:45
> To: [EMAIL PROTECTED]
> Subject: Re: [fpc-pascal]Apple Mac pointer problem
> 
> 04-09-23 23.09, skrev Stephen Downs följande:
> 
> > -Original Message-
> > From:Marcel Martin [mailto:[EMAIL PROTECTED]
> > Sent:Thu 9/23/2004 9:18 PM
> > To:[EMAIL PROTECTED]
> > Cc:
> > Subject:Re: [fpc-pascal]Apple Mac pointer problem
> >
> > Stephen Downs a écrit :
> >>
> >> I am porting a Mac CodeWarrior project to FreePascal and have hit a
> >> compile problem with a pointer. In my original code I have a structure
> >> defined along the lines of
> >>
> >> testData = record
> >> testIndex :  array [0..12] of integer;
> >> end;
> >>
> >> testDataPointer = ^testData;
> >> testDataHandle = ^testDataPointer;
> >>
> >> Within my main code I open a file and try to read it into my structure
> >>
> >> testDataHdl := testDataHandle(NewHandleClear(sizeof(testData)));
> >> OSError := FSRead(fileRefNum, numberOfBytes, testDataHdl^)
> >>
> >> The FSRead line fails with error: 62: Incompatible type for arg no. 3:
> >> Got "testDataPointer", expected "Ptr" - the third parameter for FSRead
> is a
> >> pointer. I presume this is because FreePascal uses typed pointers.
> 
> The reason you get the error msg is that fpc supports UNIV as a dummy
> keyword. Is it is accepted but doesn't do anything.
> 
> Since the third param is declared UNIV you do not need any typecast in
> Metrowerks, but you need to cast to Ptr in fpc (as Marcel suggests).
> 
> From UI:
> 
> FUNCTION FSRead(refNum: INTEGER; VAR count: LONGINT; buffPtr: UNIV Ptr):
> OSErr;
> 
> >> I
> >> tried replacing testDataHdl^ by Ptr(testDataHdl)^ but that gives a
> >> similar error - Got "ShortInt", expected "Ptr"
> 
> The mac type Ptr is defined as usual in the UI, as a pointer to a signed
> byte, hence the reference to ShortInt in the error msg, which is a signed
> byte.
> 
> >> Does anyone know how I can get around this?
> >
> >> This is very likely a stupid suggestion but have you tried this
> >>
> >> Ptr(testDataHdl^)
> 
> > I had tried that and it compiles ok but when it runs, the FSRead
> statement
> > returns an error -36 which is an I/O error
> 
> Are you shure nothing else is wrong ?
> 
> If you read a binary file, alignment might not be the same.
> 
> Actually FPC does not align arrays the same as trad mac compilers.
> 

Thanks for everyones input (Harold - it a Mac thing !!). I'm away for a couple of days 
now so won't be able to follow up until next week but I guess I need to read up on 
alignment of binary data.

I assume from what you are saying is that Ptr(testDataHdl^) is the right way to do it 
in FreePascal but I need to check on how the data is read into the structure.

> Olle
> 
> 
> ___
> fpc-pascal maillist  -  [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Apple Mac pointer problem

2004-09-24 Thread Olle Raab
04-09-24 09.44, skrev Stephen Downs följande:

> 
> Thanks for everyones input (Harold - it a Mac thing !!). I'm away for a couple
> of days now so won't be able to follow up until next week but I guess I need
> to read up on alignment of binary data.
> 
> I assume from what you are saying is that Ptr(testDataHdl^) is the right way
> to do it in FreePascal but I need to check on how the data is read into the
> structure.

If the problem is the alignment, you can try to read element by element.

Olle


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal