Oh nein,eine E-Mail ....von MIR >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<A.ECKLEDER(a)CHATEAU.ZER.SUB.ORG
....i put a well working procedure into a unit,but this does not seem to
work :(
what …
[View More]reasons can this have ? (again i use some functions of another unit
from there)
andy
/------------------ A.ECKLEDER(a)CHATEAU.ZER.SUB.ORG -------------------\
bleibt die Frage: Wie kommt Scheisse auf's Dach ?!?
\-------------------- ANDY(a)TIMEWARP.INSIDER.ORG ----------------------/
## CrossPoint v3.1 ##
[View Less]
Oh nein,eine E-Mail ....von MIR >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<A.ECKLEDER(a)CHATEAU.ZER.SUB.ORG
....i just tried to get some dos memory via dpmi in the unit start block
( to begin do )
…
[View More]i use a function call to another unit there (linked with import)
which calls the extender function (get dos mem) then.
to specify this a little more: i do NOT want to have a selector (this is
made later),i just want to have some memory allocated for a call-buffer.
is it a problem that i call a function of another unit there?!?
thanx for help,
andy
/------------------ A.ECKLEDER(a)CHATEAU.ZER.SUB.ORG -------------------\
bleibt die Frage: Wie kommt Scheisse auf's Dach ?!?
\-------------------- ANDY(a)TIMEWARP.INSIDER.ORG ----------------------/
## CrossPoint v3.1 ##
[View Less]
At 12:01 PM 11/2/96 -0700, you wrote:
>Hi,
>
>I read somewhere that GNU has a Win95 version. If this is true where can I
>get it? Is there anything else I need to download?
>
Let me just repeat the announcement:
README for cygwin32 GNU Pascal
------------------------------
The latest cygwin32-compatible GNU Pascal binary is now available from:
ftp://agnes.dida.physik.uni-essen.de/home/janjaap/cygwin32/
I keep this …
[View More]seperate from the main release directory because some things
have to be done before the next all-platform release. Still, the win32
GPC has improved enough that I think you should all try it out.
Files in this directory:
gpc-960930-2.7.2.i386-cygwin32-b16.zip
Sep.30 snapshot binary of cygwin32 GPC. For a cygwin32-beta16
toolchain.
gpc-961006-2.7.2.i386-cygwin32-b16.zip
Oct.06 snapshot binary of cygwin32 GPC. For a cygwin32-beta16
toolchain. Essentially the same, but unstripped exe's.
devtools.i386-cygwin32-b16.zip
For those who only want to do Pascal, it's a waist to download a
complete toolchain from ftp.cygnus.com. This archive has all the
tools (as, ld, libraries) needed to complete GPC.
If you already have cygwin32-beta16 installed, you don't need
this.
Changes
-------
Since the last release (gpc-1.2-2.7.2.i386-cygwin32-b14.zip), these things
have changed:
* Now beta16 compatible.
* Fixed internal fork() problems, now --automake works.
* Pipes (`gpc -pipe ...') supported.
* Binary/text file IO problem fixed.
* Some new test programs.
* Support for function attributes and multiple directives per function
declaration. Effectively, this means this GPC can access the Win32 API
and build both GUI and console applications! Thanks, Peter.
See the demos in the "test\windows" subdirectory.
Installation
------------
* create a subdirectory of your choice (`c:\gpcwin32') and unzip
gpc-96MMDD-2.7.2.i386-cygwin32-b16.zip and devtools.i386-cygwin32-b16.zip
from there. Use a version of `unzip' that can handle long filenames,
i.e. not PKunzip.
* Add the directory where `gpc.exe' lives (`c:\gpcwin32\bin') to your
path.
* Set GCC_EXEC_PREFIX=C:\gpcwin32\lib\gcc-lib\
Beware of the trailing slash!
* Set LIBRARY_PATH=c:\gpcwin32\lib;c:\gpcwin32\i386-cygwin32\lib
Not yet done
------------
GPC has incomplete support for the `stabs' debugging format. This affects
the win32 platform (and all ELF unices). Although you can step your
program in GDB, it may lose track of where you really are, be unable to
display variables etc. I'm working on this.
The function attributes and asmname directives seem to get lost in the GPI
mechanism, so you will have to #include `units' for now, if they define
WinAPI type functions.
Other problems
--------------
These things often give problems:
* Do NOT mix binaries from different beta's -- they are incompatible.
* Be sure to have only one `cygwin.dll' in your path and it must be
beta16.
The symptoms of these are crashes, stack/register dumps and Windows
telling you it cannot load a dll.
Read the cygwin32 FAQ (http://www.cygnus.com/ or this directory)
Most of the information also applies for GNU Pascal.
And please, do not bother the people of the cygwin32 mailinglist if you
have problems with GPC, send them to the gpc(a)hut.fi list instead.
Have fun,
JanJaap <j.j.vanderheijden(a)student.utwente.nl>
--
"Nothing shocks me, I'm a scientist", Indiana Jones
[View Less]
Hello folks,
perhaps somebody can help me with a strange error which occurs
when using Strings under FreeBSD. (It does not occur on DJGPP,
EMX, or Linux.)
The error is triggered by the program
Program Crash;
Type
WrkString = String ( 80 );
Var
S: WrkString;
begin
S:= 'A';
if S = 'A' then
writeln ( 'Hurra!' );
end.
It compiles fine, the assembly code looks nice, but it gets a signal
"iot" (whatever that means) when running. The error …
[View More]happens in the
RTS function _p_string() (see rts/rts-string.c):
/* First arg is always a string or char */
if (argument_mask & P_STR_FIRST_IS_CHAR)
{
c1 = va_arg (p, char);
s1 = &c1;
len1 = 1;
}
else
{
/* It's a string */
s1 = va_arg (p, char *);
len1 = va_arg (p, int); /* <------ SIGIOT */
}
When examining the variables with gdb, everything looks nice, too.
*p == 'A', etc.
A similar error happens when running the following variant:
Program Crash;
uses
CPtr;
Var
C: Char value 'A';
P: CharPtr;
begin
P:= @C;
if P^ = 'A' then
writeln ( 'Hurra!' );
end.
It is essential that the type "CharPtr = ^Char" is exported by a
Unit, not declared in the program.
First, we get a warning about assignment of incompatible pointers for
"P:= @C" which is, of course, nonsense, but I can explain it with the
mechanism of forward references in pointer declarations.
Again, the assembler code looks fine, but when running the program,
I get a signal. :(
And again, the error does not occur with DJGPP, EMX, or Linux - only
with FreeBSD.
DOES ANYBODY HAVE AN IDEA?
Yours,
Peter
e-mail: peter.gerwinski(a)uni-essen.de
home address: D\"usseldorfer Str. 35, 45145 Essen, Germany
WWW: http://agnes.dida.physik.uni-essen.de/~peter/
[View Less]
Hi,
I read somewhere that GNU has a Win95 version. If this is true where can I
get it? Is there anything else I need to download?
TIA,
Amy Williams
epic(a)aros.net
http://www.aros.net/~epic/
Finger for PGP public key.
At 08:04 AM 10/29/96 -0800, you wrote:
>hi,
>
>i download this file gpc-1.1p2-linuxelf.tar.gz from some ftp site, and
>i'm confused. The below executable is in this file, but there is no
>source.
Sources, info etc.: follow the pointers at the homepage:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/
>
>-rwxr-xr-x root/root 48100 Dec 20 09:53 1995 usr/bin/gpc
>
>
>i get the following error on a simple pascal program. i don't know pascal
>so i'm assuming …
[View More]it right
>
>/lib/libm.so.5.0.5: undefined reference to `__errno_location'
>
>program Mytestfile (input, output);
>procedure HI;
> begin
> {GotoXY(1, 23);}
> {WRITE("Hi");}
> end;
>
>BEGIN { main program }
>
> HI;
>
>END.
>
I would not expect to much output from this program ;-)
>next, i then downlaod the latest and i'm still getting the same error :<.
>
>-rwxr-xr-x 1 root root 50348 Aug 28 14:15 /usr/bin/gpc*
>
>rf600:~$ gpc -v
>Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.2/specs
>gpc version 1.2(2.7.2)
>rf600:~$ gpc tst.pas
> /lib/libm.so.5.0.5: undefined reference to `__errno_location'
>
Are you sure you get an error when _compiling_ your test program, not when
_running_ it ???? The GPC compiler itself does not use libm.so in any way,
so this error message doesn't make any sense. But programs compiled with GPC
always use libm.so
>
>
>any and all help will be greatly appreciated
>
As far as I can see, (1) you don't have a GPC problem, but your
version of libm and libc don't match or (2) you have a very old/new libc
version which has an errno definition incompatible with the one used by the
GPC precompiled binary. The 2.6.3 based GPC binary is linked against
libc.so.5.0.9 (the one from Slackware 3.0) while the 2.7.2 based GPC
binaries are linked against libc.so.5.2.18. I believe libm is version 5.0.5
in both cases. You can check your installed libc version:
ZOO-station:~$ ldd /usr/bin/gpc
libc.so.5 => /lib/libc.so.5.2.18
The dynamic loader is complaining because it cannot resolve a symbol,
"__errno_location" which is indeed undefined in libm.so:
ZOO-station:~$ nm /lib/libm.so.5 | grep __errno_location
U __errno_location
("U" means undefined). But this symbol is defined in <errno.h> and should be
present in libc.so:
ZOO-station:~$ nm /lib/libc.so.5 | grep __errno_location
0000fe4c W __errno_location
To make sure it's not GPC who's causing trouble, try compiling a small piece
of C which uses libm.so, i.e.:
int main(void)
{
printf("sine of 0 = %f\n", sin(0));
}
If it's the problem described by (1) then this should produce the same sort
of errors.
Usually, a libc.so is backwards compatible, but if you have a libc.so < 5.0.9
it may be time to upgrade. If will not use experimental libc versions (5.3.x,
5.4.x) to produce the precompiled GPC binaries, because I don't want to
force people to upgrade to these versions. If you use an experimental
libc.so version, see if the errno definition in <errno.h> has changed since
5.2.18 (I cannot verify this -- I don't have it). If so, you may have to
rebuild libgpc.a because it uses the errno definition.
In the 5.2.18 <errno.h> it's defined like this:
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
extern int* __errno_location __P((void));
#define errno (*__errno_location ())
#else
extern int errno;
#endif
Hope this helps, otherwise it might be useful to see your results for the
tests described above.
JanJaap
--
The latest & greates in software, hardware and manswear
-- Bono Vox (U2)
[View Less]
hi,
i download this file gpc-1.1p2-linuxelf.tar.gz from some ftp site, and
i'm confused. The below executable is in this file, but there is no
source.
-rwxr-xr-x root/root 48100 Dec 20 09:53 1995 usr/bin/gpc
i get the following error on a simple pascal program. i don't know pascal
so i'm assuming it right
/lib/libm.so.5.0.5: undefined reference to `__errno_location'
program Mytestfile (input, output);
procedure HI;
begin
{GotoXY(1, 23);}
{WRITE("Hi");}
end;
BEGIN { main …
[View More]program }
HI;
END.
next, i then downlaod the latest and i'm still getting the same error :<.
-rwxr-xr-x 1 root root 50348 Aug 28 14:15 /usr/bin/gpc*
rf600:~$ gpc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.2/specs
gpc version 1.2(2.7.2)
rf600:~$ gpc tst.pas
/lib/libm.so.5.0.5: undefined reference to `__errno_location'
any and all help will be greatly appreciated
michael b. williams
mbw(a)rf600.es.hac.com
[View Less]
On Thu, 24 Oct 1996 08:25:26 +0100,
Niels Heirbaut <heirbaut(a)pi.net> wrote:
>Hi,
>
>Hereby I would like to thank everybody who helped me getting GPC-2.7.2
>started. Their hints and tips really helped me getting started.
>
[...]
>So if someone would add the (revised?) installation instruction and the
>SPECS.GPC file to the binary *.ZIP file, or if someone could tell me how
>(I'm also a newbie at uploading to FTP-sites :-)) and where to upload the
>revised …
[View More]gpc272b.zip file, the problems I had will be forever in the past.
>
All my fault :-(
I'll try to be more carefull in the future. There's a "prerelease" and
several snapshots floating around, so I'll try to clean up the mess a bit.
Greetings,
JanJaap
---
"Nothing shocks me, I'm a scientist", Indiana Jones
[View Less]
Hello folks,
Seems this crappy M$dos email proggy is not capable of attaching unix text
:-(
Let me try again:
This is Info file FAQ, produced by Makeinfo-1.64 from the input file
faq.texi.
Revision 0.2 of 24 October 1996
Author: J.J. van der Heijden <j.j.vanderheijden(a)student.utwente.nl>
What is GNU Pascal?
*******************
The purpose of the GNU Pascal project is to produce a Pascal compiler
(called GNU Pascal or GPC) which
* combines the clarity of Pascal with …
[View More]powerful tools suitable for
real-life programming,
* supports both the Pascal standard and the Extended Pascal standard
as defined by ISO, ANSI and IEEE. (ISO 7185:1990, ISO/IEC
10206:1991, ANSI/IEEE 770X3.160-1989)
* supports other Pascal standards (UCSD Pascal, Borland Pascal,
Pascal-SC) in so far as this serves the goal of clarity and
usability,
* may be distributed under GNU license conditions
* can generate code and run on any computer for which the GNU C
compiler can generate code and run.
Pascal was originally designed for teaching. GNU Pascal provides a
smooth way to proceed to challenging programming tasks without learning
a completely different language.
What is the current version of GNU Pascal?
==========================================
The last official release is GPC 1.1, based on GCC version 2.6.3.
GPC version 1.2, based on GCC 2.7.2 is currently in beta testing.
Where is the GNU Pascal FTP site? WWW?
======================================
The master FTP site for GNU Pascal is kampi.hu.fi GNU Pascal related
files can be found in:
ftp://ftp.kampi.hut.fi/jtv/gnu-pascal/
This site is mirrored on:
ftp://sunsite.doc.ic.ac.uk/gnu/pascal/
The latest developer releases can be downloaded from:
ftp://agnes.dida.physik.uni-essen.de/
Also, we have a homepage on the web:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/
Is it compatible with Turbo Pascal (R) ?
========================================
GPC is currently *not* a drop-in replacement for Borland's Turbo
Pascal (R). It supports a number, but not all of the Borland
extensions to the Pascal language. There is no replacement for most of
the Borland runtime library functions. GNU Pascal is part of the GNU
project, so portability is one of its primary goals. For this reason,
non-portable features of Borland Pascal will probably not be included
into GNU Pascal. More information can be found in the section "Borland
Pascal" of the GPC manual.
Installation related questions
******************************
This section discusses some common problems with the installation of
GNU Pascal.
Which platforms are supported by GNU Pascal?
============================================
GPC uses the GCC backend, so it should run on any system that is
supported by GNU CC. This includes a large variety of Unix systems,
MS-DOS, OS/2 and Win32. A full list of platforms supported by GCC can
be found in the file "INSTALL" of the GCC distribution. Not all of
these have actually been tested, but the gpc-1.2 pre-release is know to
run on these platforms:
i486-linux (Linux 2.x, ELF)
i486-linuxaout
i486-linuxoldld
i486-freebsd2.1
i386-cygwin32 (Windows95/Windows NT)
i386-djgppv2 (MS-DOS)
i386-emx (OS/2, MS-DOS)
mips-sgi-irix5.3
>>> Ok people - send us your success stories, with canonical machine
name! <<<
Which components do I need to compile Pascal source code?
=========================================================
A complete Pascal compiler system should at least have:
* The actual compiler, GPC.
* Assembler, linker, librarian and friends.
* A C library.
* A debugger, if you want to debug your programs.
You don't need a C compiler to compile your Pascal programs, but you
do need it to build the GNU Pascal compiler itself. GNU Pascal version
1.1 is based on GCC 2.6.3, GPC v1.2 is based on GCC v2.7.2 Any attempt
to build GPC with the wrong version of GCC is bound to fail.
For most people, the GNU binutils and GNU debugger (gdb) are a good
choice, although some may prefer to use vendor specific tools.
Help! linking gpc1 fails: _emit_string_move undefined (and more)
================================================================
If linking `gpc1' bombs out with an error message that looks like
this:
ld: Undefined symbol
_emit_string_move
_emit_string_pad
_maybe_find_function_data
_dbxout_set_type_status
_version_flag
*** Error code 1
make: Fatal error: Command failed for target `gpc1'
you probably suffer from a VPATH make problem. A few GPC source
files have counterparts with identical name in the GCC source
directory. When you have built GCC in the GCC source directory and you
are not using a recent version of GNU make this problem may occur.
There are three solutions:
* Get a recent version of GNU make. Version 3.74 or better is known
to work.
* Build GCC in a seperate directory instead of using the GCC source
directory.
* Manually delete these files from the GCC object directory:
`stor-layout.o dbxout.o expr.o fold-const.o optabs.o convert.o'
`function.o setop.o toplev.o'
then resume `make'.
When I build libgpc.a, rts-rt0.c says: SIGXCPU undefined (and more)
===================================================================
Compilation of the runtime system may fail in rts-rt0.c with a
message simular to this:
rts-rt0.c: `SIGXCPU' undeclared (first use this function)
or:
rts-rt0.c: storage size of `sv' isn't known
rts-rt0.c: storage size of `osv' isn't known
If this happens to you, you have to edit the rts/rts-config.h file
and comment out the last line to:
/* #undef HAVE_SIGSYS */
This will be fixed in a future release.
I'm using unix, and all my Pascal programs have linking problems.
=================================================================
A number of unix configurations use their system's linker instead of
GNU ld. Usually, GPC and GCC need a program called `collect2' before
calling the system's `ld'. `collect2' is installed by GCC, and if you
only install GPC, it will not find collect2, and use the system linker
directly, which will result in various linker errors. The solution is
to copy `collect2' by hand from the GCC directory to the location where
`gpc1' lives.
I do I debug my Pascal programs?
================================
To debug your programs, (a) GNU Pascal must be able to generate
executables with debug info for your platform, and (b) you must have a
debugger which understands this.
* If `gpc -g -o hello hello.p' says: "gpc: -g not supported for this
platform", then GPC is unable to generate debug info. Usually,
installing GAS instead of your system's assembler can overcome
this. When you configure the GCC used for GPC, specify
"-with-gnu-as", and possibly "-with-gnu-ld" and/or "-with-stabs".
More information can be found in "INSTALL" file in the GNU CC
source directory.
* Your system's debugger may not understand the debug info generated
by GNU tools. In this case, installing GDB may help.
The bottom line: if you can debug GCC compiled programs, you should
be able to do this with GPC too.
The GNU debugger (GDB) currently does not have a "Pascal" mode, so
it is unable to display certain Pascal structures etc. When debugging,
please note that the Initial Letter In Each Identifier Is In Upper Case
And The Rest Are In Lower Case. If you want to display variable 'foo'
in the debugger, type `show Foo' or `display Foo' instead.
Can you recommend an IDE?
=========================
Users of Borland Pascal may wonder if there's a replacement for the
IDE (Integrated Development Environment). Here's a few suggestions:
* *(X)Emacs*. Some people think it's the answer to the question of
Life, the Universe and Everything, others decide it's uGNUsable.
Available from your friendly GNU mirror.
* *XWPE* is an immitation of the Borland IDE, so users of Borland
Pascal may find it a good alternative.
Although GDB is an excellent debugger, it's user interface is not
very attractive. Refer to the comp.windows.x FAQ: "Where can I get an
X-based debugger?" at:
http://www.cis.ohio-state.edu/hypertext/faq/usenet/x-faq/part6/faq-doc-2.ht…
Some useful frontends include: XXGDB, tGDB and XWPE. see:
http://www.ee.ryerson.ca:8080/~elf/xapps/Q-IV.html
Very nice, but resource consuming is the Motif based DDD:
http://sol.ibr.cs.tu-bs.de/softech/ddd/
Do we have a binary for you?
============================
Currently, we have binaries for these platforms:
i486-linux (ELF)
i486-linuxaout
i486-linuxoldld
djgpp V2 (msdos)
emx 0.9B (OS/2, msdos)
cygwin32 beta16 (Windows95, Windows NT)
mips-sgi-irix5.3
New binaries may have been added after the release of this FAQ.
GNU Pascal and your system libraries
************************************
This section discusses common problems people have when they try to
access their system's libraries.
How do I use <insert_your_function_here> from the C library?
============================================================
GNU Pascal can use every function of your C library, but it may be
up to you to write declaration of an external function, before you can
use it. Consider the function `sleep'. man(3) sleep reveals:
---------------------------------------------------------
NAME
sleep - Sleep for the specified number of seconds
SYNOPSIS
#include <unistd.h>
unsigned int sleep(unsigned int seconds);
---------------------------------------------------------
This small demo program shows how to use `sleep' in a Pascal program:
---------------------------------------------------------
program SleepDemo;
type
word = __unsigned__ integer;
function sleep(seconds: word): word; C;
var
result : word;
begin
result := sleep(10);
end.
---------------------------------------------------------
What's this confusion about Pascal and C style strings?
=======================================================
It is important not to confuse Pascal and C string types.
* The Pascal string schema, as defined in section 6.4.3.3.3 of the
ISO-10206:1990 Extended Pascal standard, is a record:
type string = record
Capacity : integer;
length : integer;
string : packed array [ 1..Capacity ] of char;
end;
'string' is not 'string(256)', unlike Turbo Pascal. The capacicty
must be declared:
type
MyString = string(256);
before it can be used, i.e.:
function MyFunction: MyString;
* A C string ( "char *" ) is an array of char, terminated with a
NULL char.
C library functions require C, not Pascal style string arguments!
Consider this code snippet to convert Pascal style strings to C style
and vice versa:
---------------------------------------------------------
type
word = __unsigned__ integer;
TString = string(256); { Pascal string schema }
CString = __cstring__; { C style string }
{ Convert a "C" string to a "Pascal" string }
function StrPas(Src: CString): TString;
var
S : TString;
begin
S := '';
if (Src <> NIL)
then while ( (Src^ <> chr(0)) AND (length(S) < S.capacity)) do
begin
S := S + Src^;
inc(Word(Src));
end;
StrPas := S;
end;
{ Convert a "Pascal" string to a "C" string }
function StrPCopy(Dest: CString; Src: String): CString;
var
c: integer;
p : CString;
begin
p := Dest;
for c:=1 to length(Src) do
begin
p^ := Src[c];
inc(word(p));
end;
p^ := chr(0);
StrPCopy := Dest;
end;
---------------------------------------------------------
Then this small example will print the PATH:
---------------------------------------------------------
Program EnvDemo;
{ include the above StrPas() and StrPCopy() snippet here }
{ C library function prototype: char *getenv(const char *name); }
function GetEnv(name : CString): CString; C;
var
pName: CString;
begin
getmem(pName, 256);
pName := StrPCopy(pName, 'PATH');
writeln('Your PATH is: ', StrPas(GetEnv(pName)));
freemem(pName, 256);
end.
---------------------------------------------------------
And this is how you access the 'system()' call in you C library:
---------------------------------------------------------
program SysCall;
{ include the above StrPas() and StrPCopy() snippet here }
function system(name : CString): integer; C;
var
pName: CString;
result : integer;
begin
getmem(pName, 256);
pName := StrPCopy(pName, 'ls -l');
result := system(pName);
writeln('system() call returned : ', result);
freemem(pName, 256);
end.
---------------------------------------------------------
There may be other ways to do the same thing; you could declare a
type PChar instead of CString:
type PChar = ^char;
and replace all references to `CString' with `PChar'. Do NOT pass a
"C" style string as a var-argument if the C prototype says "const char
*" or you will get a coredump.
You are right if you think this stuff belongs in a library, to be
distributed with GPC. Have patience, or start coding!
Are GNU Pascal objects compatible with GNU C++ classes ?
========================================================
No. (This may change in a future version)
Where are the Turbo Pascal (R) replacement units?
=================================================
They don't exist (yet). Most of their fuctionality can easily be
implemented, some things are very x86/msdos dependant and would be
meaningless on any other platform.
How do I build/use a shared library?
====================================
(topic under construction)
GNU Pascal on the djgpp (MS-DOS) platform
*****************************************
This chapter discusses some potential problems with GNU Pascal on
MS-DOS, using djgpp.
If you need more information
============================
GPC/djgpp is a djgpp V2 application, and most of the djgpp
documentation applies for GPC too. A great source of information is the
djgpp FAQ:
http://www.delorie.com/djgpp/v2faq/faq202b.zip
Another place to look for DJGPP documentation is the DJGPP Knowledge
Base, at this URL:
http://www.delorie.com/djgpp/doc/kb/
What do I download?
===================
As discussed in section 2.2, other than GPC itself, you need an
assembler, linker and friends, a C library and possibly a debugger.
>From your local djgpp mirror, you can get these as:
v2/djdev200.zip (C library)
v2gnu/bnu252b.zip (assembler, ....)
v2gnu/gdb412b.zip (debugger)
The rest is up to you; 'make' (v2gnu/mak372b.zip) can be useful,
RHIDE (an IDE with Borland-look) is nice, but still under development.
Future releases of RHIDE may have better GPC support.
How do I install the compiler?
==============================
If you don't have djgpp installed on your harddisk, create a
directory for GNU pascal ("c:\gpc"), and unzip the archives. Make sure
you preserve the directory structure (use "pkunzip -d"). Now, add the
directory where gpc.exe lives ("c:\gpc\bin") to your path and set the
DJGPP environment variable to point to your djgpp.env file:
set DJGPP=c:\gpc\djgpp.env
Then, add this to your djgpp.env file:
---------------------------------------------------------
[gpc-cpp]
C_INCLUDE_PATH=%/>;C_INCLUDE_PATH%%DJDIR%/lang/pascal;%DJDIR%/include;%DJDIR%/contrib/grx20/include
[gpc]
COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin
LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib;%DJDIR%/contrib/grx20/lib
---------------------------------------------------------
The binary distribution should come with a `djgpp.env' which is
already modified, so you may not have to do this.
Specific information for low-memory conditions and more can be found
in the djgpp FAQ and documentation.
GPC says: no DPMI
=================
You don't have a DPMI server installed, and DJGPP v2 requires it to
run. You can either use one of the commercial DPMI servers (e.g., run
`gpc' in a DOS box under Windows) or download and install CWSDPMI
(`csdpmi3b.zip') which is a free DPMI server written for DJGPP.
I cannot read the info pages!
=============================
To read the info pages, you need the `info' program from txi360b.zip.
At least for some of the pre-releases of gpc-1.2, the gpc.info file is
invalid: it refers to the "gpc.i*" sections as "gpc.info-*". This can be
fixed by loading gpc.inf in an editor and replacing "gpc.info-*" with
"gpc.i*"
I have troubles with assembly code
==================================
The GNU Assembler (`as.exe'), or `gas', called by GCC accepts "AT&T"
syntax which is different from "Intel" syntax. Differences are
discussed in section 17.1 of the djgpp FAQ.
A guide is available which was written by Brennan Mr. Wacko Underwood
<brennan(a)mack.rt66.com> and describes how to use inline assembly
programming with DJGPP, at this URL:
http://www.rt66.com/~brennan/djgpp/djgpp_asm.html
Section 17.3 of the djgpp FAQ discusses some methods to convert
"Intel" syntax to "AT&T".
Tell me how to do DPMI, BIOS and other DOS related things.
==========================================================
DPMI, BIOS and other functions are no different than other system
functions. Refer to section 3.1 how to access your system's C-library.
This small example shows how to use DPMI, copying some structures and
function prototypes of <dpmi.h>:
---------------------------------------------------------
program dpmitest;
{$X+}
type
word = __unsigned__ integer;
short = __short__ integer;
byte = __byte__ integer;
type
PDpmiVersionRet = ^TDpmiVersionRet;
TDpmiVersionRet = record
major : byte;
minor : byte;
flags : short;
cpu : byte;
master_pic : byte;
slave_pic : byte;
end;
type
PDpmiFreeMemInfo = ^TDpmiFreeMemInfo;
TDpmiFreeMemInfo = record
largest_available_free_block_in_bytes : word;
maximum_unlocked_page_allocation_in_pages : word;
maximum_locked_page_allocation_in_pages : word;
linear_address_space_size_in_pages : word;
total_number_of_unlocked_pages : word;
total_number_of_free_pages : word;
total_number_of_physical_pages : word;
free_linear_address_space_in_pages : word;
size_of_paging_file_partition_in_pages : word;
reserved1 : byte;
reserved2 : byte;
reserved3 : byte;
end;
function DpmiGetVersion(ret: PDpmiVersionRet): integer;
asmname '__dpmi_get_version';
function DpmiGetFreeMemoryInformation(info: PDpmiFreeMemInfo): integer;
asmname '__dpmi_get_free_memory_information';
var
version: TDpmiVersionRet;
meminfo: TDpmiFreeMemInfo;
begin
DpmiGetVersion(@version);
writeln('CPU type : ', version.cpu, '86');
writeln('DPMI major : ', version.major);
writeln('DPMI minor : ', version.minor);
DpmiGetFreeMemoryInformation(@meminfo);
writeln('Free DPMI memory : ', meminfo.total_number_of_free_pages, ' pages.');
end.
---------------------------------------------------------
I'm accessing an "array[1..4000000] of byte" and I got an exception.
====================================================================
Per default, the maximum stack size of a djgpp application is 256K.
If you need more, you have to adjust it with the stubedit program, i.e.:
stubedit your_app.exe minstack=5000K
Still, it might be a good idea to use pointers for this kind of
structures, and allocate the memory at runtime.
Getting Help
************
This section discusses ways to get help with GNU Pascal. Please read
the documentation (info files, readme's) that come with GPC, plus other
docs that might help (the djgpp FAQ if you use djgpp etc.) before you
send email to the maintainers or mailing list.
Help! the compiler crashed!
===========================
If the compiler crashes, you have discovered a bug. A reliable
compiler never crashes. To help the maintainers fix this bug, it is
important that you send us a problem report.
I think I found a bug - now what?
=================================
Bugs are best reported to the GPC mailinglist, gpc(a)hut.fi. That
way, they always reach the maintainers. Try to give as much information
as possible, plus a short code snippet that triggers the compiler bug.
If you're on unix, you can find out where the compiler crashed if you
enable coredumps, then load the compiler (gpc1) plus the core file in
the debugger ("gdb /your_path_here/gpc1 core"), then type `backtrace'
to get a stacktrace. Include this stacktrace in your bug report.
Which newsgroup(s) are suited for GPC related problems?
=======================================================
There are several Pascal related newsgroups, but none is dedicated
just to GNU Pascal. This one may be useful:
comp.lang.pascal.misc Pascal in general and ungrouped Pascals.
Pascal syntax related questions may be appropriate in:
comp.lang.pascal.ansi-iso Pascal according to ANSI and ISO standards.
comp.lang.pascal.borland Borland Pascal questions.
How to post to the mailing list
===============================
You can send a message to the GPC mailing list by sending email to
the list address <gpc(a)hut.fi> as if it were a person.
How to become a subscriber to the mailing list
==============================================
You can join the mailing list by sending a message to
<gpc-request(a)hut.fi> (NOT <gpc(a)hut.fi> !) with your request to be added
to the list. Maintenance is done by hand, so some delay is possible.
How to unsubscribe from the mailing list
========================================
To leave the mailing list, send a message to <gpc-request(a)hut.fi>.
Miscellaneous
*************
I want to contribute; where do I start?
=======================================
A list of jobs which should be done for GNU-Pascal can be found in
the section "How to contribute of the Texinfo deocumentation. In cases
where somebody is already working on a topic, the name of that person
is written behind the job's description.
This does not mean that you shouldn't do that but just that you
should get in contact with that person if you would like to contribute
to that field.
About this FAQ.
===============
Maintainer: J.J. van der Heijden
<j.j.vanderheijden(a)student.utwente.nl>
This is the first incarnation of the GNU Pascal FAQ list. Comments
about, suggestions for, or corrections to this FAQ list are welcome.
Please make sure to include in your mail the version number of the
document to which your comments apply (you can find the version at the
beginning of this FAQ list).
Much of the info in this FAQ list was taken from the gpc mailing
list traffic, so you may have (unbeknownst to you) contributed to this
list.
---
"Nothing shocks me, I'm a scientist", Indiana Jones
[View Less]
On Wed, 23 Oct 1996 02:03:57 -0400 (EDT),
John Michael Black <jm_black(a)csunix1.lvc.edu> wrote:
>There's been a lot of getenvs going around here lately. :) Has anyone
>found a method that works yet? The last thing posted about it gave this:
>
> Function GetEnv ( Name: __CString__ ): PChar; C;
>
>GPC does not recognize PChar -- at least ours doesn't.
>
>This could go on for weeks.... :)
Naah....
Take this:
(*
* Demonstrate the conversion of "Pascal"…
[View More] string schemas to "C" style
* strings and back, and calling an external "C" style function.
*
* J.J. van der Heijden <j.j.vanderheijden(a)student.utwente.nl>
*)
Program EnvDemo;
type
word = __unsigned__ integer;
TString = string(256); { Pascal string schema }
CString = __cstring__; { C style string }
{ Convert a "C" string to a "Pascal" string }
function StrPas(Src: CString): TString;
var
S : TString;
begin
S := '';
if (Src <> NIL)
then while ( (Src^ <> chr(0)) AND (length(S) < S.capacity)) do
begin
S := S + Src^;
inc(Word(Src));
end;
StrPas := S;
end;
{ Convert a "Pascal" string to a "C" string }
function StrPCopy(Dest: CString; Src: String): CString;
var
c: integer;
p : CString;
begin
p := Dest;
for c:=1 to length(Src) do
begin
p^ := Src[c];
inc(word(p))
end;
p^ := chr(0);
StrPCopy := Dest;
end;
{ C library function prototype: char *getenv(const char *name); }
function GetEnv(name : CString): CString; C;
var
pName: CString;
begin
getmem(pName, 256);
pName := StrPCopy(pName, 'USER');
writeln('Hello ', StrPas(GetEnv(pName)), ' !');
pName := StrPCopy(pName, 'PATH');
writeln('Your PATH is: ', StrPas(GetEnv(pName)));
freemem(pName, 256);
end.
There are multiple ways to do this: for example, you can also declare a
type PChar = ^char;
and replace every instance of CString with PChar. Works great.
Do not pass a CString argument as a "var" if it's declared as "const char *"
in C; you will definately get a coredump. (in C too BTW)
I tested this with Linux and djgpp (dos) GPC, 1.2 prerelease.
The GPC-1.1 may have troubles with the function returning a TString schema.
Let me know if it doesn't work for you, though I can't imagine that.
JanJaap
---
"Nothing shocks me, I'm a scientist", Indiana Jones
[View Less]