Sign in Join

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

Mailing lists / lazarus / 2026-03

Lazarus bindings to C/C++ libraries

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Chavoux Luyt

Hi guys,

This is more of a learning question than anything to do with the implementation of Lazarus. It kind of connects to the previous topic of LCL widgetsets and dynamic/static binding. But maybe I am not the only Lazarus user to wonder about it (e.g.
https://forum.lazarus.freepascal.org/index.php?topic=51480.0), which answers one of my questions already. I was wondering if fpc still used the Pascal calling convention (1st two parameters stored in registers and the others pushed on the stack, also pushed in the opposite order to C, IIRC)? It seems like that, because it still uses ;cdecl; extern; to access the C library functions.

Many moons ago I wrote a (relatively small) device driver for a USB device in windows (in C -- I think all device drivers are written in C and/or assembler? - probably true in Linux as well, although I assume that Linux would expect a slightly different API?). In turn, my Delphi program would access the driver through a Delphi class in a wrapper Unit (I did not bother to create a visual component for that, IIRC).

*My question* is if the same "Pascal wrapper" to access C libraries technique is used by Lazarus to access the various OS Windows/Widgetsets, as you would do for a device driver? I assume that Lazarus can use any device driver written in C, as long as the API is clear and public? [I.e. no need to have the C source file.]

Just asking to learn, so if you know about an existing. nice concise and complete, online source explaining it all, please feel free to tell me to RTFM and provide the link.

Thank you!
Chavoux

+27 82 791 1384
www.newdevelopment.co.za
www.chavoux.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20260316/0a1ef92b/attachment.htm>

Reply by email

n7800
to Chavoux Luyt
Show quoted text 5 lines
Just asking to learn, so if you know about an existing. nice concise and complete, online source explaining it all, please feel free to tell me to RTFM and provide the link.

Perhaps these links will answer some of your questions:

* https://www.freepascal.org/docs-html/current/prog/progse28.html

* https://www.freepascal.org/docs-html/current/prog/progse22.html

* https://www.freepascal.org/docs-html/current/ref/refse98.html

* https://www.freepascal.org/docs-html/current/ref/refse100.html -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20260316/2c9b29df/attachment.htm>

Reply by email