[fpc-pascal] dereferenced pointer as open array argument

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Sep 21 13:12:47 CEST 2015


Seth Grover wrote on Fri, 18 Sep 2015:

> procedure ArrayTest(const data : array of char);
...
> However, it surprised me that this syntax was accepted (with a dereferenced
> pchar):
>
> ArrayTest(myPChar^);
>
> as well as this syntax (with a simple char):
>
> ArrayTest(myChar);
>
> In both of those cases, ArrayTest thinks it's got an array of length 1.
>
> My question is (and I know this is a long shot): is there some sort of
> compiler directive or directive I can include in my source code to disallow
> the syntax of my second and third examples, ie., to disallow passing a
> single element as an open array?

No, there is no such directive. This behaviour has been there from the  
start when open arrays were initially added to Turbo Pascal.


Jonas



More information about the fpc-pascal mailing list