[lazarus] Libc.ErrNo and TControl.DoMouseWheel

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Wed Dec 31 05:39:04 EST 2003




On Wed, 31 Dec 2003, Marc Weustink wrote:

> At 08:29 31-12-2003, Den Jean wrote:
> >Hi,
> >
> >I am porting code from Kylix to Lazarus
> >and I have a few questions:
> >
> >1) ErrNo from Libc does not compile
> >
> >     eg uses Libc;
> >          writeln(Libc.ErrNo)
> >
> >     gives error messages:
> >     undefined reference to `errno'
> >     Error:Error while linking
> >
> >    But if you click on ErrNo it shows its definition in Libc
> >    I use it after call to setsockopt
> 
> If it is defined in the libc unit it doesn't mean that it can linked (it 
> has to be in the libc library aswell)
> But that's probably not the case here. IIRC, erno is a var and there was 
> something with exported vars and libraries

The point is that glibc no longer exports the libc 'errno' variable on newer
systems. This has broken many C programs, and is also completely incompatible 
with the libc units. I have fixed the units (see cvs) but this means that 
those units can no longer be used by default on old systems. 

Here is the explanation I put in the README file that accompagnies the
Libc unit:

-----------------------------------------------------------------------
Note on the Libc errno variable. On recent systems the errno symbol is no
longer published in libc. It has been replaced by a __errno_location
pointer, with a macro in the C header files to mask this. The pascal 
Libc files assume this by default. This also means you cannot set the 
errno value directly, you must use the 'seterrno' procedure for that.
(see errno.inc)

The old mechanism of a published errno libc variable is still available 
by setting the LIBC_OLDERRNO define when compiling the libc units.
-----------------------------------------------------------------------

At a later stage we can maybe try to detect it at run-time.

Michael.






More information about the Lazarus mailing list