[fpc-pascal] libusb header translation and OOP wrapper

Christo christo.crause at gmail.com
Tue Oct 2 23:53:08 CEST 2012

On Mon, 2012-10-01 at 23:04 +0200, Johann Glaser wrote:
> The major changes are that you use LoadLibrary instead of dynamic
> linking at program start. Note that $LINKLIB is really doing dynamic
> linking, not static linking. Therefore I don't see why procedural
> variables should be needed here.

I actually didn't have to go the Loadlibrary route, you are right.  I
have changed the "external;" attribute to "external dllname;' and just
specify dllname at the top of the unit - see attached diff.

> Secondly you test whether libusb_get_port_number() and
> libusb_get_port_path() are available. I don't know how to handle this
> properly. Why not just update to 1.0.12?

I also can't think of a proper way to test.  Perhaps just add a comment
next to these function declarations in libusb.pas to remind users these
functions may not be implemented in older libusbx versions?

> Third, at some points you added the unit CThreads. Looking at the
> libusbx source code (and API documentation) reveals, that they don't use
> threading, they only use the mutexes (pthread_mutex_*) and condition
> variables (pthread_cond_*). I also don't know whether it is necessary to
> install the Pascal Thread Manager therefore. I'll start a dedicated
> thread for that.

After making several changes and upgrading to libusbx 1.0.14 I no longer
require CThreads to run the test in Debian. I'm not sure why I needed it

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dif.zip
Type: application/zip
Size: 3088 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121002/d27f4cef/attachment.zip>

More information about the fpc-pascal mailing list