[Gambas-devel] Re: Linking to a c library (libxxx.so.0

Joris Meijer jorisenpetra at ...182...
Wed Nov 10 22:28:54 CET 2004


On Wed, 2004-11-10 at 16:46 +0100, Benoit Minisini wrote:
> On Tuesday 09 November 2004 20:22, Joris Meijer wrote:
> > Here is the latest example off a possible way to dynamically link with a
> > C-library without knowing the function prototy at compile time. It does
> > not giva a answer to all the questions but answers some.
> 
> Cool. But this is "user" mailing-list: post on "devel" mailing-list, the other 
> one :-)
> 
> I think you should restore the stack after having called the function in the 
> dynamic library.

I believe that according to C calling convention you should, after a
funtion call restore the SP. So probebly you are right ;-)

A easy but slow way off restoring stack is to pop the arguments from the
stack witch were pushed there.
> 
> >
> > About the portebility, I think it is portable but to where would you
> > like to port??
> 
> Something other than x86: PowerPC for example.
I think the general idee should work for all platforms although a big
enidian might couse some problems. But these problems would be
fixable:-)

Probebly the inline assembly would need to be adjusted for non gcc
compilers but it is not a lot off assembly so this would not be that big
a deal.

I think the example is not perfect but it shows that it is possible to
link to a C-library without knowing the function prototype at compile
time. I would like to know how you think about it and if you think it
possible to include such a feature in gambas??

greetz Joris Meijer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_dl.tar.gz
Type: application/octet-stream
Size: 3656 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20041110/7d08b485/attachment.obj>


More information about the Devel mailing list