[fpc-pascal] libc and math.h on Linux

Marco van de Voort marcov at stack.nl
Fri Feb 2 15:30:20 CET 2018

In our previous episode, Adriaan van Os said:
> I have to import the math.h libc functions listed here
> <http://pubs.opengroup.org/onlinepubs/009695399/toc.htm>.  What is the
> recommended way to do this for general Linux compatibility ? 

Not do this ? :-)

>  Simply declare them external ?  Load them from libc dynamically ?

Just declare them external in a separate unit, mathc or so and keep them in
your project.

>  Anything else ? 

Macros, structured constants etc, obviously might require extra work(and
mathh has some, like the is* functions are typically macros)

Long double is probably 10-byte extended, but verify that by compiling and
running a small C program for your distro.

> I know that the FPC runtime lib itself jumps through some hoops to be as
> independent of libc (or a specific version of libc) as possible.

The FPC RTL can use libc (compile with -DFPC_USE_LIBC), but this is nowadays
little tested outside of OS X, and maybe a couple of smaller targets.

The libc policy is due a multitude of small issues, some of which might be
historic, and the idea was to allow the maintainer to chose what approach
fits his target best.

Anyway it only touches redistributable code to be merged with FPC to keep
the .tar somewhat distribution indepedent. For your private stuff you don't
have to worry about it.

More information about the fpc-pascal mailing list