[fpc-pascal] Ansi strings

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Sep 1 11:50:26 CEST 2006


On 31 aug 2006, at 13:13, Carsten Bager wrote:

> Here is 2 examples of how the fpc compiler dos when comparing a
> string constant with a pchar . The first is compiled with the 204
> compiler and second one is compiled with the 202 compiler.

The reason we now favour ansistring of shortstring in case of pchars  
is that pchars can be longer than 255 characters. In the particular  
case you mention (comparing a pchar with a constant string < 255  
characters) a shortstring would be possible too, but the type  
conversion code here does not look at the contents of the nodes, only  
a their types.

> I am using the compiler on an embedded Arm 7 platform and Ansi
> strings is not an option.
> I want to force the 204 compiler to use short strings but the only
> option I can se, that have anything to do with strings is the (-Sh use
> ansistrings) and that is just the opposite of what I want.
> Any hints?

You cannot force this other than by explicitly typecasting the pchar  
to shortstring in the comparison.


Jonas



More information about the fpc-pascal mailing list