[fpc-devel] Apache header translation Patch

Inoussa OUEDRAOGO inoussa12 at gmail.com
Mon Nov 12 10:47:50 CET 2007


> > This is the c prototype ( type ) translated, actualy it is a array
> > of PCHAR.
> >
> > <code taken from apache source>
> > const char *(*take_argv) (cmd_parms *parms, void *mconfig,
> >                            int argc, char *const argv[]);
> > </code>
> >
> > Is the following translation valid ?
> >
> > take_argv_t = function (parms: Pcmd_parms; mconfig: Pointer; argc:
> > cint; argv: array of PChar): PChar; cdecl;
>
> I think it's better to do this:
>
> take_argv_t = function (parms: Pcmd_parms; mconfig: Pointer;
> argc:cint; argv: PPChar): PChar; cdecl;
>
> You can still index it as an array in FPC, but it's clearer what the
> actual type is that gets passed (an "array of pchar" is the same as a
> double pointer to char in C). I was indeed wrong about the varargs
> stuff I said earlier, for some reason I had read "array of pchar" as
> "array of const".
Ok, Thanks.

By the way, h2pas should also be corrected, because it translates
  <code langage=c>
    void f(int a, char* p[]);
  </code>

to
  <code langage=pascal>
    procedure f(a:longint; p:array of pchar);cdecl;external;
  </code>

-- 
Inoussa O.



More information about the fpc-devel mailing list