Recent

Author Topic: FPC 3.2.2 - fpc_char_to_ansistring -  (Read 382 times)

paule32

  • Sr. Member
  • ****
  • Posts: 280
FPC 3.2.2 - fpc_char_to_ansistring -
« on: October 27, 2024, 09:55:44 am »
Hi,
I am again  ;D
On my own system.pas, I get faced with this Code:

Code: Pascal  [Select][+][-]
  1. var
  2.   S1: String;
  3.   ch: Char;
  4. begin
  5.   S1 := S1 + ch;
  6. end;

and I get this message:
Error: Incompatible type for arg no. 3: Got "AnsiString", expected "Pointer"

for:

Code: Pascal  [Select][+][-]
  1. function  fpc_char_to_ansistr (const c : Char; cp : TSystemCodePage): AnsiString; compilerproc;

I get no system error about my own system.pas - only the Error above.
Has it to do with system.pas ?
How can I fix this issue ?

Thanks for helping hands
paule32

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: FPC 3.2.2 - fpc_char_to_ansistring -
« Reply #1 on: October 27, 2024, 10:28:24 am »
You got 2 args in this proc, the error is probably in: fpc_ansistr_concat as its called right after.

Code: Pascal  [Select][+][-]
  1. procedure fpc_ansistr_concat(var dst: Pointer; const S1,S2: Pointer; cp: DWORD); compilerproc;
  2. var
  3.     S1Len, S2Len, S3Len: SIZE_T;
  4.     DestS: Pointer;
  5. begin
  6.     S1Len := strlen( S1 );
  7.     S2Len := strlen( S2 );
  8.    
  9.     dst := VirtualAlloc(nil, S1Len + 1,
  10.     MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE );
  11.    
  12.     if not (dst = nil) then
  13.     begin
  14.         FillChar( dst, S1Len, #0 );
  15.         strcpy( dst, S1 );
  16.         strcat( dst, S2 );
  17.     end else
  18.     begin
  19.         MessageBox( 0, 'Error: fpc_AnsiStr_Concat memory allocation fail.', 'Error', 0 );
  20.         ExitProcess( 1 );
  21.     end;
  22. end;

How does my code in RTL look and it works:

Code: Pascal  [Select][+][-]
  1. procedure fpc_ansistr_concat(var dests: RawByteString; const s1, s2: RawByteString; cp: TSystemCodePage); compilerproc;
  2. begin
  3.   pointer(dests) := new_ansistring(length(s1)+length(s2));
  4.   move(s1[1], dests[1], length(s1));
  5.   move(s2[1], dests[length(s1)+1], length(s2));
  6. end;

You can see it at my private repo you have access to.

EDIT: Or, edit your fpc_char_to_ansistr to return Pointer, not AnsiString; BTW. it currently doesnt return anything.
« Last Edit: October 27, 2024, 11:17:02 am by Fibonacci »

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: FPC 3.2.2 - fpc_char_to_ansistring -
« Reply #2 on: October 27, 2024, 11:17:54 am »
Thanks.
- Your Code and effort looks good.
- You are on the right way - some parts, I have stolen for own tests.
- You made the projects private - for a surprise :-) ?

- You take effort for x86 i386 ?
- my own takes for x86_64

it is good to hear, and see, that both ABI's are introduce.
« Last Edit: October 27, 2024, 11:20:15 am by paule32 »

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: FPC 3.2.2 - fpc_char_to_ansistring -
« Reply #3 on: October 27, 2024, 11:23:22 am »
I work on x86 (easier to debug), but the goal is to make it work on both. I have no idea if it compiles for x64. I dont see why it wouldnt.

The repo is private because Im shy :-[ I will open it to public when the time is right.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: FPC 3.2.2 - fpc_char_to_ansistring -
« Reply #4 on: October 27, 2024, 12:11:10 pm »
I did start the documentation - you have see it ?
They comes in three version's - html, pdf, and chm.
And these I would provide two version's - English, and German with help of doxygen.

Doxygen is currently/mainly available for C/C++ source code documentation.
But like you can see, it can both PAS and CPP.
« Last Edit: October 27, 2024, 12:35:17 pm by paule32 »

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: FPC 3.2.2 - fpc_char_to_ansistring -
« Reply #5 on: October 27, 2024, 12:32:37 pm »
Imho, potential users of this project are likely familiar with FPC, so they don't need explanations on things like FOR loops. The official FPC documentation covers that. Your documentation should only include topics that differ from standard FPC, highlight any missing features that might be expected to exist, or introduce to new features that aren't available in the original FPC.

Let's move this discussion in our GitHub "organization"  :P Folks here aren't really interested in our somewhat "private" conversation. They're even starting to act weird when the topic of a "custom RTL" comes up and are trying to dissuade you from pursuing it.

EDIT: removed this part cos you removed your edit
« Last Edit: October 27, 2024, 12:44:27 pm by Fibonacci »

 

TinyPortal © 2005-2018