[fpc-pascal]External variables in FPC

md md at realmwireless.com
Thu Nov 23 20:46:30 CET 2000

Peter, the reason I make this statement is that there was no guidance on
to build the shared library except the fact that I had a concept that I
to implement.

But hitting so many gotchas forced me to change things around a good

This update served to inform other developers of those headaches.  If
things change
and FPC does support external, PIC, and cvar a bit better, then maybe
the considerations might change.

The point being that I want to share my gotchas with others to
contribute to the community at large.

For now, FPC 1.0.2 developers should consider structuring shared
libraries a certain way.

The shared library seems to work very nicely, so I do not know why you
would argue against shared libraries
at this point.

I like the delphi mode with its automatic dereferencing of structure
pointers instead of requiring ^.
There are more reasons.  Much of my windows code moves over to linux
without "cleaning" up all of it.

Mark Diener

Peter Vreman wrote:
> > This is an update for all FPC developers using FPC under Linux.
> >
> > If you ever need to create FPC coded shared library  (XXX.SO) make use
> > of variables which are also used by either a pascal or C application
> > using the shared library,  make sure you provide a function to pass
> > pointers to storage allocation to the library so that the library uses
> > pointers to the variables while the application can access them
> > directly.
> I would even say: Don't create shared libraries yet, becuase FPC doesn't support PIC code.
> >
> > Avoid "EXTERNAL" and "CVAR" like the plague.
> >
> > The {$MODE} compiler switch causes all sorts of headaches when trying to
> > create a shared library with exported
> > variables in the shared library. Delphi mode does not allow for it, only
> > FPC mode.  But most of the code is
> > in delphi mode anyway.
> That is your personal opinion. FPC mode is more restrictive and forces you to create much
> cleaner code.
> If you know how delphi allows to export variables will add support for it.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

More information about the fpc-pascal mailing list