I need to use some libc functions and types (localtime_r, tm, ...) but there's very confusing situation with libc (they say it is deprecated) and it even couldn't be found by Lazarus when I write "uses libc". But there are no things I heed in the RTL. So what should I do?
Mailing lists / lazarus / 2012-01
Libc functions and types
11 messages · 5 people · –
- UUdav 5
- MMarco van de Voort 3
- AAndreas Schneider 1
- CCraig Peterson 1
- SSven Barth 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Well, I guess one option is to rebuild RTL with FPC_USE_LIBC defined. Another one is to define needed structures myself and implement function calls via syscall - what, I believe, is recommended way. But how can I determine the number of the function I want to call?
Udav wroteWell, I guess one option is to rebuild RTL with FPC_USE_LIBC defined. Another one is to define needed structures myself and implement function calls via syscall - what, I believe, is recommended way. But how can I determine the number of the function I want to call?
Unit libc is deprecated, yes, but its functionality is not. Most functionality is available via different units like BaseUnix and so on. A "grep -ri TheStructureYouSearch $fpcdir/rtl" should often help you in finding your structure (it should often work with functions as well).
Regards,
Sven
Sven, I tried searching inside RTL and localtime_r() is only declared in the libc/newlibc units. I think I'd have to use it because I'm trying to make my units RAD/FPC compatible and RAD uses libc for POSIX code and doesn't worry about it.
Udav wroteSven, I tried searching inside RTL and localtime_r() is only declared in the libc/newlibc units. I think I'd have to use it because I'm trying to make my units RAD/FPC compatible and RAD uses libc for POSIX code and doesn't worry about it.
With "RAD" do you mean "Delphi"? Because "RAD" stands for Rapid Application Development and does not really fit into the context of the rest of your message.
Andreas Schneider wrote
Show quoted text 5 lines
Yeah, I mean Emb-ro RAD Studio (namely XE2 as they introduced multi-platform support in this version)
Udav wrote 6 lines
There is no Embarcadero Radstudio that supports Linux. In ancient times there was Kylix, but it was buried. A part of it escaped, called unit libc, but we finally caught up with it, and now it is dead and buried too.
Just in case, I'm sitting on the grave with a shotgun.
Read all about here: http://wiki.freepascal.org/libc_unit
Marco van de Voort wroteThere is no Embarcadero Radstudio that supports Linux. In ancient times there was Kylix, but it was buried. A part of it escaped, called unit libc, but we finally caught up with it, and now it is dead and buried too.
And now they have the Posix.* units which provide the same functionality in a more cross-platform manner. The original poster gave localtime_r as a specific example. It's part of the OpenGroup's Unix specification (in time.h), but FreePascal only exposes it in libc.pas. If you don't want people using that header you really should provide a better alternative than just making everyone redeclare everything in their own units.
Marco van de Voort wrote
Show quoted text 6 lines
They have MacOSX support in XE2 and surely will do Linux in the next version.
Craig Peterson wrote
Show quoted text 6 lines
Absolutely! And if one just try searching through FPC RTL files for "tm" record he'll find it is declared about 8 times in various units.
And now they have the Posix.* units which provide the same functionality in a more…
Craig Peterson wrote 7 lines
Not supported by FPC atm.
The original poster gave localtime_r as a specific example. It's part of the OpenGroup's Unix specification (in time.h), but FreePascal only exposes it in libc.pas.
FPC doesn't expose it in any portable manner.
If you don't want people using that header you really should provide a better alternative than just making everyone redeclare everything in their own units.
Patches and submissions of such units are welcome. Note that this is the first time that this has come up.
For calls for which it has come up more frequently, this has already happened (password and network resolving among others)
Marco van de Voort wrote They have MacOSX support in XE2 and surely will do Linux in the…
Udav wrote 6 lines
That's perfectly logical because every *nix version has its own version. (and they might even differ between architectures. Linux specially has that tendency due to x86 legacy)
