----- Forwarded message from "Alexei P. Baturin" bat@niipmm.tsu.ru -----
From: "Alexei P. Baturin" bat@niipmm.tsu.ru To: gpc-owner@gnu.de Subject: Questions about GNU Pascal Date: Thu, 15 Aug 2002 16:49:39 +0700
Good day, Would you like to answer two questions about GNU Pascal (MS DOS with DGJPP) for which I haven't found the answer in documentation? I work in MS-DOS under Windows 98 (processor Pentium II).
1. Is it possible to force the functions sin, cos, exp, ln, **, etc. to calculate a result of type LongReal (10 bytes) with a precision of 19 decimal digits (as in BP or Delphi)?
2. How to use DLL's in GP-programs? I tried to import a function from DLL by usual way (as in Delphi):
function esin(x:extended):extended; external 'extenlib.dll' index 1;
but the compiler didn't understand this. Can you help me to solve this problem?
Best regards, Alexei Baturin (Tomsk, Russia)
----- End forwarded message -----
On 16 Aug 2002 at 5:49, Dieter Schmitz wrote:
----- Forwarded message from "Alexei P. Baturin" bat@niipmm.tsu.ru
From: "Alexei P. Baturin" bat@niipmm.tsu.ru To: gpc-owner@gnu.de Subject: Questions about GNU Pascal Date: Thu, 15 Aug 2002 16:49:39 +0700
Good day, Would you like to answer two questions about GNU Pascal (MS DOS with DGJPP) for which I haven't found the answer in documentation? I work in MS-DOS under Windows 98 (processor Pentium II).
- Is it possible to force the functions sin, cos, exp, ln, **, etc. to
calculate a result of type LongReal (10 bytes) with a precision of 19 decimal digits (as in BP or Delphi)?
Dunno. But I would be surprised if it wasn't.
- How to use DLL's in GP-programs? I tried to import a function
from DLL by usual way (as in Delphi):
function esin(x:extended):extended; external 'extenlib.dll' index 1;
but the compiler didn't understand this. Can you help me to solve this problem?
It's not so straightforward. You need to have an import library for your dll (e.g., libmydll.a) that you would link. Otherwise, (under Windows) you could always use LoadLibrary and GetProcAddress.
With regard to the syntax, under Windows, you would do something like: function esin(x:extended):extended; asmname 'esin'; attribute(stdcall); I have no idea what you would do under djgpp.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~African_Chief email: African_Chief@bigfoot.com
Prof Abimbola Olowofoyeku wrote:
Would you like to answer two questions about GNU Pascal (MS DOS with DGJPP) for which I haven't found the answer in documentation? I work in MS-DOS under Windows 98 (processor Pentium II).
- Is it possible to force the functions sin, cos, exp, ln, **, etc. to
calculate a result of type LongReal (10 bytes) with a precision of 19 decimal digits (as in BP or Delphi)?
Dunno. But I would be surprised if it wasn't.
This happens automatically if the system library provides `sinl' etc. functions. This doesn't seem to be the case under DJGPP. So you might want to ask the DJGPP developers if/when this will be supported (should be rather easy to do, they'd basically have to copy the code from Linux/IA32, I guess).
Frank
Frank Heckenbach wrote:
Prof Abimbola Olowofoyeku wrote:
Would you like to answer two questions about GNU Pascal (MS DOS with DGJPP) for which I haven't found the answer in documentation? I work in MS-DOS under Windows 98 (processor Pentium II).
- Is it possible to force the functions sin, cos, exp, ln, **, etc. to
calculate a result of type LongReal (10 bytes) with a precision of 19 decimal digits (as in BP or Delphi)?
Dunno. But I would be surprised if it wasn't.
This happens automatically if the system library provides `sinl' etc. functions. This doesn't seem to be the case under DJGPP. So you might want to ask the DJGPP developers if/when this will be supported (should be rather easy to do, they'd basically have to copy the code from Linux/IA32, I guess).
I use a workaround meanwhile. There is a free library which contains all these functions: the CEPHES library available at
http://www.moshier.net/#Cephes
Download cephes28.zip, the MSDOS distribution, and compile the ldouble library (contained in the ldouble sundirectory): you will need to check the makefile and mconf.h : some parameters correspond to the linux case. You will get a libml.a library you will put in the %DJDIR%\lib standard DJGPP library directory. To use it from gpc you will need an import unit. I attach the one I use. Simply put uses libml, ... in your main program tu use it. In this unit you will probably have to comment out the declararations for the operators pow and ** until the bug I reported in an other mail will be corrected (meanwhile you can copy the declarations into your main program). Also probably not all transcendental functions are imported: it contains the ones I have used up to now with pascal names according to my taste.
In fact it is possible now to integrate this library into libm.a, and to compile gpc so that gpc knows automatically all the standard pascal functions (the "standard pascal" functions flagged in the libml.pas import unit). But you will need anyway the import unit for the other transcendantal functions so that I find rather useless to publish a special version of gpc which would incorporate this stuff.
Maurice