[fpc-pascal] Ansi strings

Carsten Bager carsten at beas.dk
Fri Sep 1 12:00:46 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.

I have discovered that I can use the {$LONGSTRINGS OFF} 
directive, is this a god way or should I typecast? It would be nice if 
there were a switch that could be put in the CFG file that forced the 
compiler to use short strings.

> 
> 
> Jonas
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal





More information about the fpc-pascal mailing list