Results 1 to 4 of 4

Thread: Problem while porting string code to FPC

  1. #1

    Problem while porting string code to FPC

    Hey,

    I've been trying to get some code working with FPC, however it chokes on the following line:

    [pascal]
    procedure TNashaLogger.Write(aLogStr: String);
    begin
    FLog.Add(aLogStr);

    {$IFDEF MSWINDOWS}
    OutputDebugString( PChar(aLogStr) ); << HERE
    {$ENDIF}
    end;
    [/pascal]

    G:\n3d\workingdir\src\n3d_log.pas(91,22) Error: Illegal type conversion: "ShortString" to "^Char"
    Does the keyword String refer to a shortstring in FPC?

    I have placed the following at the top of my unit:
    [pascal]
    {$IFDEF FPC}
    {$MODE Delphi}
    {$ENDIF}
    [/pascal]

    But it doesn't really help. Can anyone tell me what I can do to fix this?

    I would be really thankfull if someone gave me an article that helps you port delphi code to FPC. Especially the small differences in functionality, strings, types etc would be good to know about.

    Thanks in advance.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    Re: Problem while porting string code to FPC

    Try this at the top of your unit(s):

    [pascal]{$IFDEF FPC}
    {$MODE Delphi}
    {$ENDIF}
    {$H+}
    [/pascal]
    H+ is to turn long strings on by default, see if this helps

    cheers,
    Paul

  3. #3

    Re: Problem while porting string code to FPC

    Thanks paul.. that works.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: Problem while porting string code to FPC

    If you are using Lazarus you can set it in your Compiler options by going (in your menu) to Project -> Compiler Options... then go into your 'Parsing' tab and under Syntax Mode (-M) choose Delphi.

    I do this in each of my own projects and it works quite well when using Delphi-style syntax.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •