[fpc-devel] Embedded Strings on nRF51-DK

Paul Michell Paul at michellcomputing.co.uk
Thu Apr 16 14:43:48 CEST 2015


On Thursday 16 Apr 2015 14:19:38 Sven Barth wrote:
> First of: I don't know whether non-Shortstrings are supported on embedded
> (I haven't played with that target yet). So my following tips are geared
> towards ShortString usage.
> 
> Which compiler mode are you using? You should use either mode FPC or at
> most ObjFPC. Mode Delphi will switch on AnsiString. In any case you should
> ensure that you haven't enabled AnsiStrings using $H+ (simply disable the
> directive in that case).
> Additionally you could declare your String variables explicitly as
> ShortString instead of String.
> 
> Regards,
> Sven

I've tried mode FPC and ObjFPC with both long and short strings.  I have just 
tried again with the ShortString type as well (I've included the whole main 
unit code below for reference).  

I suspect that I need to link additional object files that support the string 
handling, but I don't know which ones, nor if this is possible with the 
embedded compiler?

Thanks,

Paul

--------------------------------------------
Unit Main;

{$Mode FPC}
{$LongStrings OFF}

Interface

Uses 
  NRF51, UART; 

Function Main: Integer; Cdecl;

Implementation

Function Main: Integer; Cdecl; Alias: 'main';
Const
  RXDPIN = 11;
  TXDPIN = 9;
  CTSPIN = 10;
  RTSPIN = 8;
Var
  Text: ShortString;
Begin
  Text := 'Hello World';
  UARTConfigure(RTSPIN, TXDPIN, CTSPIN, RXDPIN, True);
  UARTPutString(Text);
End;

End.



More information about the fpc-devel mailing list