Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-04

FPC 2.4.1 with library that requires old libc unit.

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I'm trying to update a set of database components (FBLib) used with tiOPF. In FPC 2.2.0 (32bit linux) everything compiled and worked fine. Today I tried to compile my latest version of FBLib (as is found in tiOPF repository) with FPC 2.4.1 (64bit linux). I don't know if the following problems are related to 32bit -> 64bit switch or because of FPC 2.2.0 -> FPC 2.4.1 switch.

1) First I had the problem that FPC couldn't find 'Libc' unit used in the uses clause. No idea why - maybe Libc unit is only 32bit? Anyway, I replaced 'Libc' in uses clause with 'baseunix' and continued...

2) This got me a bit further, to the code shown below. Is there a baseunix equivalent to Libc.mblen()? Can anybody help me resolve this compilation issue?

This URL describes what mblen() does:
http://www.delorie.com/djgpp/doc/libc/libc_558.html

--------------------------------

function TFBLScript.CStrNextChar(const AStr: PChar): PChar;
{$IFDEF UNIX}
var
  CharLen: Integer;
{$ENDIF}
begin
  {$IFDEF UNIX}
  CharLen := Libc.mblen(AStr, MB_CUR_MAX);     // <<-----
  if (CharLen = -1)
    then CharLen := 1;
  Result := AStr + CharLen;
  {$ELSE}
  Result := CharNext(AStr);
  {$ENDIF}
end;
--------------------------------

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Jonas Maebe
to Graeme Geldenhuys
Graeme Geldenhuys wrote
1) First I had the problem that FPC couldn't find 'Libc' unit used in the uses clause. No idea why - maybe Libc unit is only 32bit?

Yes, it is.

2) This got me a bit further, to the code shown below. Is there a baseunix equivalent to Libc.mblen()?

No, there is not. You have to manually import it from the C library. You can look at rtl/unix/cwstring.pp to see the declaration of this function for various platforms (note that it's mbrlen() in most cases -- that one is preferable to mblen() because mblen() is not thread- safe).

Jonas

Reply by email

Marco van de Voort
to Graeme Geldenhuys: I'm trying to update a set of database components (FBLib) used with tiOPF. In FPC 2.2.0…

In our previous episode, Graeme Geldenhuys said:

1) First I had the problem that FPC couldn't find 'Libc' unit used in the uses clause. No idea why - maybe Libc unit is only 32bit? Anyway, I replaced 'Libc' in uses clause with 'baseunix' and continued...

In addition to Jonas:

Libc is a Linux/32-bit legacy Kylix unit, see

http://wiki.freepascal.org/libc_unit

Reply by email

Graeme Geldenhuys
to Jonas Maebe: Yes, it is. No, there is not. You have to manually import it from the C library. You can…

Jonas Maebe het geskryf:

> uses clause. No idea why - maybe Libc unit is only 32bit? Yes, it is.

What I expected due to Kylix compatibility.

Show quoted text 5 lines
No, there is not. You have to manually import it from the C library. You can look at rtl/unix/cwstring.pp to see the declaration of this function for various platforms (note that it's mbrlen() in most cases -- that one is preferable to mblen() because mblen() is not thread- safe).

Thank you very much. I manually imported that function and FBLib works fine now under FPC 2.4.1 64bit. No more requirements on the old Libc unit for 32bit and 64bit systems. :-)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email