Re: [fpc-pascal] Translate C code

2018-01-06 Thread Sven Barth via fpc-pascal
Am 06.01.2018 12:23 schrieb "Ryan Joseph" : > On Jan 6, 2018, at 5:25 PM, Karoly Balogh (Charlie/SGR) < char...@scenergy.dfmk.hu> wrote: > > So it doesn't crash, because it never loads from this "invalid" address it > calculates. Are we talking about the address on

Re: [fpc-pascal] Translate C code

2018-01-06 Thread Ryan Joseph
> On Jan 6, 2018, at 5:25 PM, Karoly Balogh (Charlie/SGR) > wrote: > > So it doesn't crash, because it never loads from this "invalid" address it > calculates. Are we talking about the address on the stack at compile time? If no memory was ever allocated (which I

Re: [fpc-pascal] Translate C code

2018-01-06 Thread Giuliano Colla
Il 06/01/2018 01:39, Darius Blaszyk ha scritto: #define MEMNEXT(x) ((MyStruct *)(((char *) x) - ((char *) & (((MyStruct *)0)->next h2pas translates it into the enclosed file. Hope that it helps. Giuliano darius.pp Description: application/wine-extension-pp

Re: [fpc-pascal] Translate C code

2018-01-06 Thread Karoly Balogh (Charlie/SGR)
Hi, On Sat, 6 Jan 2018, Ryan Joseph wrote: > Also why does @(PMyStruct(nil)^.next not crash? Dereferencing and taking > the addressing of a nil pointer sounds like a bad idea. Because it doesn't do the actual dereferencing, because next's *VALUE* is never used, only it's address (due to the @

Re: [fpc-pascal] Translate C code

2018-01-06 Thread Ryan Joseph
> On Jan 6, 2018, at 1:49 PM, Karoly Balogh (Charlie/SGR) > wrote: > > type > PMyStruct = ^TMyStruct; > TMyStruct = record >some, fields: integer; >next: PMyStruct; > end; > > function MEMNEXT(x: Pointer): PMyStruct; > begin >

Re: [fpc-pascal] Translate C code

2018-01-06 Thread Darius Blaszyk
Well, not sure why one needs to do this abomination, without knowing the data structure it operates on, but nevertheless, you can do the same in Free Pascal, but you better turn the macro into a function: Thanks Charlie! ___ fpc-pascal maillist -

Re: [fpc-pascal] Translate C code

2018-01-05 Thread Karoly Balogh (Charlie/SGR)
Hi, On Sat, 6 Jan 2018, Darius Blaszyk wrote: > Again I would like to ask some support on a piece C code that I need to > translate to pascal. The code in question is: > > #define MEMNEXT(x) ((MyStruct *)(((char *) x) - ((char *) & (((MyStruct > *)0)->next > > What exactly is going on here?

[fpc-pascal] Translate C code

2018-01-05 Thread Darius Blaszyk
Hi all, Again I would like to ask some support on a piece C code that I need to translate to pascal. The code in question is: #define MEMNEXT(x) ((MyStruct *)(((char *) x) - ((char *) & (((MyStruct *)0)->next What exactly is going on here? Where does the result point to? It seems like it