On Unix, the RTL can link to libc see defne "FPC_USE_LIBC". It would be a good start.
Moreover, I'd like to provide thicker or Pascal-ish bindings and not just thin wrapper ove C API, so wonder where I can look about the general procedures how to do it, some helper tools etc.?Depending on the available header files, h2pas may help getting the thin wrapper. The thick part must be written by hand, and it depends on how thick you want it to be. I don't have small examples for this, there's a big one in fpgtk package, which wraps the thin wrapper into Object Pascal classes. Otherwise, you can keep the interface procedural but make the parameters more Pascalish by replacing PChar-s with strings and pointers with var parameters. For instance:
[ there's a big one in fpgtk package,That one is way to complex for most, hence I mentioned the bindings for SQlite: both serious and understandable.
You will need:
- the C header file
- h2pas (and possibly h2paspp) to parse it. (and cpp -E and copy/paste abilities for the nerdy ones to resolve all C macro's)
- C knowledge AND Pascal knowledge
- Patience. Even with the above tools, you will need manual adjustments
On the bright side is that C headers can almost always be translated into Pascal.
Once the basic header translation is done, you can objectify it on top of that.
Sqlite is a good way to start. It is an easy example of all the above. Even for persistent beginners.(Because Sqlite is exemplary well written C code)
Note such a task is not always for beginners: it needs an intermediate to advanced programming knowledge in both C and Pascal.
FreeBASIC uses msvcrt.dll freely.
The bindings are all in the inc/crt folder.
Here are the layouts of the declarations in mem.bi
extern "C"
declare function memchr (byval as const any ptr, byval as long, byval as size_t) as any ptr
declare function memcmp (byval as const any ptr, byval as const any ptr, byval as size_t) as long
declare function memcpy (byval as any ptr, byval as const any ptr, byval as size_t) as any ptr
declare function memmove (byval as any ptr, byval as const any ptr, byval as size_t) as any ptr
declare function memset (byval as any ptr, byval as long, byval as size_t) as any ptr
function Printf(mask : pchar):integer; cdecl; varargs; external 'msvcrt.dll' name 'printf';
function system(s:pchar):integer ; cdecl external 'msvcrt.dll' name 'system';