[fpc-pascal] Problem translating c code to pascal
M.Santhoff at t-online.de
Sun Sep 24 17:53:37 CEST 2006
Am Sonntag, den 24.09.2006, 11:37 -0300 schrieb Felipe Monteiro de
> This is what almost works:
> hw_handlers: array[0..1] of handler_rec =
> (content_type: 'hw_app'; handler: @DefaultHandler),
> But the compiler will complain on the nil:
> mod_hello.lpr(108,5) Fatal: Syntax error, "(" expected but "NIL" found
That's why I suggested making it an array of pointers. A pointer can be
NIL. The main question is if apache can still access it in the right
Have you tried something stupid, like:
hw_handlers: array[0..1] of handler_rec =
(content_type: 'hw_app'; handler: @DefaultHandler),
> On 9/23/06, Marc Santhoff <M.Santhoff at t-online.de> wrote:
> > Think of hardware detection, one driver may know different models it
> > supports. When detection is active it simply iterates over the model
> > describing struct and checks presence until the item read from the
> > struct is NULL.
> I still don't know how what is the inner working of this. Does that c
> statement really means a static array with size two?
Yes it does.
> A record cannot
> be null. When you access a static record you go directly to it's
> memory position of Initial_Pos + X * Record_Size, where X is the
> record number. Then you cannot have a null record. The best you can
> have is record whose content is null.
There is the problem, pascal is sort of stronger typed than C.
> Or NULL could represent that the array is of size 1 not 2.
It is an element that can have a NULL value, however the compiler
interprets it. Mostly variables in C do not have anything attached but
can be viewed as a block of memory. You can do with it what you like.
Pascal is lacking some common base type compatible with any record. One
solution for a few cases would be to use an array of byte and do the
How is the source using this array defined, can you get any hints from
that C code? Is it happy with a record having a NIL string and a NIL
pointer in it?
More information about the fpc-pascal