Khimenko Victor forwarded the message by Simon Tatham:
> http://www.chiark.greenend.org.uk/~sgtatham/bugs.html is the
> definitive location. (This isn't quite the same as the Freshmeat
> version, but the differences aren't important.)
That's fine. So I think we should mention this URL prominently in
the FAQ.
Frank
--
Frank Heckenbach, frank(a)g-n-u.de
http://fjf.gnu.de/
PGP and GPG keys: http://fjf.gnu.de/plan
Khimenko Victor wrote:
> P.S. To Frank & Peter: may be we should put BIG message with link to
> http://freshmeat.net/news/2000/02/26/951627540.html
> somewhere in FAQ ?
> It's REALLY must be read by anyone who ask for help...
I think it's a good idea to mention it prominently in the FAQ.
Is this URL likely to remain permanently?
I've written some of his points into test/README. This file will be
installed as BUGS in the binary distributions in the doc directory
(e.g. /usr/local/doc/gpc/) where also the FAQ will be installed.
Russ, you might want to point to the BUGS file in the FAQ.
BTW, the other files installed in that directory will be README
(general information about GPC), AUTHORS (list of GPC authors), NEWS
(changes since the last beta) and COPYING and COPYING.LIB (GNU GPL
and LGPL).
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
Russ Whitaker wrote:
> Frank Heckenbach wrote:
>
> >
> > I'm wondering if we should suggest c.l.p.b at all. Is anyone
> > monitoring it for GPC related questions regularly? (I'm not reading
> > it anymore because of the high noise/signal ratio...)
> >
> Read the postings today. Looks like the faq should be changed to
>
> " comp.lang.pascal.borland ( It's mostly a haven for beginers )"
>
> Most of the questions would apply to any pascal and the answers came fairly
> quickly.
Probably. But I'm a bit worried, if we recommend the newsgroup in
the FAQ and people send their GPC specific problems (like
installation problems) there and no-one's reading it, that's not
good (for the users and for the reputation of GPC). Therefore my
question if anyone is reading it regularly and looking for GPC
related questions...
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
Frank Heckenbach wrote:
>
> I'm wondering if we should suggest c.l.p.b at all. Is anyone
> monitoring it for GPC related questions regularly? (I'm not reading
> it anymore because of the high noise/signal ratio...)
>
Read the postings today. Looks like the faq should be changed to
" comp.lang.pascal.borland ( It's mostly a haven for beginers )"
Most of the questions would apply to any pascal and the answers came fairly
quickly.
Thanks
Russ <russwhit(a)mind.net>
Maurice Lombardi wrote:
> What about command line defines, as
>
> gpc -DPostScript ...
>
> would it be case sensitive ? I would prefer no, but is there any problem ?
Oh right. I forgot to mention them, it's good you did...
Well, I think the implicit defines (`__GPC__', `__FOO_PASCAL__',
`DJGPP', etc.) should remain case-sensitive.
For user-supplied options, we have the choice. Again, I see reasons
to have case-sensitive ones, too. E.g., I have some programs which
work alternatively with GMP (multi-presicion) or normal numbers, and
I use `-DGMP' to select the GMP version. Since the unit is also
called `GMP', it would conflict if it's case-insensitive (whereas
now I can write `uses Gmp' to avoid a conflict).
So, we could allow both on the command-line as well, we'd just need
different option names.
The problem is that `--define' in GCC is equivalent to `-D' and
case-sensitive, and I think we shouldn't change this to keep
interoperability with GCC as good as it is now. But we could add a
new option for case-insensitive defines.
J. David Bryan wrote:
> > OTOH, something like {$define-case-sensitive} would make it clear, but
> > it's very long.
>
> {$define-cs} would be OK (better than {$definecs} only because the "cs"
> part stands out better with the hyphen).
I'd vote against the hyphen because it's an acronym that follows.
BTW, since the directive itself is case-insensitive, you could write
it as {$DefineCS} to make it clearer...
Dr A Olowofoyeku wrote:
> On 7 Apr 00, at 0:53, Peter Gerwinski wrote:
>
> > Dr A Olowofoyeku wrote:
> > >
> > > Why not use {$define} for case insensitive and #define for case
> > > sensitive ? Since case-sensitivity is a C thing, we might as well keep
> > > #define (which is also a C thing) for that purpose. Advantage? It
> > > avoids the introduction of new constructs.
> >
> > I see the advantages. But in fact we want to get rid of
> > unpascalish things such as #define and promote alternatives
> > like {$define}.
>
> I see. In this case I vote for {$csdefine} ('Case Sensitive Define')
> or {$cdefine}.
With the above consideration about the command line, I suggest
perhaps `csdefine' and `cidefine' for case-sensitive/-insensitive
defines. Both would work on the command-line and as compiler
directives. Besides, `define' as a directive is case-insensitive
(because of BP) and `--define' on the command line is case-sensitive
(because of GCC).
Or the same with `definecs', `defineci'.
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
Dr A Olowofoyeku wrote:
> On 10 Apr 00, at 10:57, Frank Heckenbach wrote:
>
> [...]
> > If there are no objections, I'm implementing:
> >
> > Case insensitive:
> >
> > {$define}
> > {$cidefine}
> > --cidefine
> >
> > Case sensitive:
> >
> > {$csdefine}
> > -D
> > --define
> > --csdefine
>
> Seems as good as any other permutation.
Probably. :-/
But at least once one has learned what ci/cs means, one can remember
those ones without looking them up...
And users of other Pascal compilers or of GCC will not encounter
unpleasant surprises...
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
At long last here's vers 3 of the proposed FAQ
If you think it looks good will start making a HTML version
russ
<russwhit(a)mind.net>
=======================================================
GNU Pascal Frequently-Asked Questions List, Edition 0.5, February 2000
by Russ Whitaker <russwhit(a)mind.net>
based on
GNU Pascal Frequently-Asked Questions List, Edition 0.4, for GPC
version 2.0, November 1996
by J.J. van der Heijden <j.j.vanderheijden(a)student.utwente.nl>
For up-to-date information, ask the GPC mailing list (see below).
Index
*****
1.0 GNU Pascal - what, where and why
2.0 Installation
3.0 After the installation
4.0 Pascal on the djgpp platform
5.0 (reserved)
6.0 Getting Help
7.0 Miscellaneous
1.0 GNU Pascal
***************
1.1 What and why?
=================
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 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.
1.2 What is the current version?
================================
The latest release as of this writing is GPC-19991030. GPC requires
GCC as a back-end. Patches for GCC 2.8.1 thru GCC 2.95.2 are provided
but it is recommended that you use at least GCC 2.95.
1.3 Is it compatible with Turbo Pascal (R) ?
============================================
GPC is *not* a drop-in replacement for Borland's Turbo Pascal (R).
Almost all BP language features are supported. Notable exceptions are
the string format (as discussed below), or the 'Mem' and 'Port' pseudo
arrays, though replacemnet functions for the latter on x86 platforms
exist in the 'Ports' unit.
Also, almost all of BP's run time library is supported in GPC
(built-in or in units with the same names as their BP counterparts).
Some notes:
- A BP compatable graph unit exists but is distributed saparately
due to its license.
- The OOP stuff (Turbo Vision etc.) is not yet completed, but work
on several projects is underway.
- Some exotic routines need an explicit `uses System' statement, or
equivalently a `--uses=system' command line option. See the system
unit for details.
- A few unportable routines are not supported in the Dos unit (see
the comments there). I think there's an older, unportable, Dos
unit which supports them (or else it's easy to write one) if you
really need those routines...
---Frank (minor edited)
1.4 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 it is known to run on these
platforms:
ix86-linux (Linux 2.x, ELF)
i486-linuxaout
i486-linuxoldld
i386-freebsd1.2.0
djgpp V2 (msdos)
emx 0.9B (OS/2, msdos)
cygwin32 beta16 (Windows95, Windows NT)
mips-sgi-irix5.3
sun-sparc-sunos4.1.4
>>> Ok people - send us your success stories, with canonical machine
name! <<<
2.0 Installation
*****************
2.1 How do I get and install GPC on my computer?
================================================
1. The easiest way is is from a distrubution - if you can find it.
All the dependency files should be there, also. The downside is if
the GPC release date is proir to Oct. 1999 you shuld plan on doing
an update.
2. The recommended way is to build it yourself from the source listings.
If you have everything you need to compile a kernal except the kernal
source then all you need is the GPC source and a GCC source. The down-
side is if you have a slow computer the build could take several
hours.
You can get the GPC source from
ftp://agnes.dida.physik.uni-essen.de/
You can get the GCC source from
http://gcc.gnu.org
3. You may not want to install a new distribution just to get GPC and
the build project on a 386 can take several hours as well as some 50M
of hard drive space. Then try one of the several pre-compiled binaries
available. The downside is you need one that is compatable with your
computer and C libruary.
GNU Pascal Compiler binaries for Sun Solaris 7 (Sparc/x86)
operating environment in native Solaris packages form are
available at:
Sparc:
ftp://mizar.uwb.edu.pl/pub/misc/solaris7/sparc
http://math.uwb.edu.pl/download/solaris7/sparc
x86:
ftp://mizar.uwb.edu.pl/pub/misc/solaris7/x86
http://math.uwb.edu.pl/download/solaris7/x86
For installation instructions read Readme.txt file on that site.
GPC 19991030 was compiled based on GCC 2.95.
Binaries for Solaris 8 (Sparc and Intel) are now available on:
http://math.uwb.edu.pl/download/solaris8/
ftp://mizar.uwb.edu.pl/pub/misc/solaris8/
-- Mariusz Zynel
Also, on Feb 9th, 2000 the following binaries were found in a
FTP directory at agnes.dida.physik.uni-essen.de:
Directory: /gnu-pascal/alpha/binary/
gpc-19990607-djgp.zip
Directory: /gnu-pascal/beta/binary/
gpc-19990118-1.i386-pc-linux-gnu.rpm
gpc-19990118-egcs-1.1.1.i386-linux-glibc2.tar.gz
gpc-19990118-egcs-1.1.1.i386-pc-mingw32.zip
gpc-19990118-egcs-1.1.1.i586-pc-linux-gnulibc1.tar.gz
gpc-19990118.alpha-unknown-linux-gnu.tar.gz
gpc-19990118.alphaev56-dec-osf4.0d.tar.gz
gpc-19990118.i386-pc-djgppv201.zip
gpc-19990118.i386-pc-emx0.9d.zip
gpc-19990118.i386-pc-mingw32.zip
gpc-19990118.i586-pc-linux-gnulibc1.tar.gz
gpc-19990118.mips-sgi-irix6.2.tar.gz
gpc-19990118.sparc-sun-solaris2.6.tar.gz
gpc-19990430-i386-pc-djgppv202.zip
gpc-extras-19990118-1.i386-pc-linux-gnu.rpm
2.2 How do I build a GPC compiler?
==================================
CAUTION: There have been extensive changes in GCC from 2.8 to 2.95.
The old GPC build instructions, for GCC-2.8 and earlier, will not work.
If you have a typical ix86 box the routine is fairly simple. Any other
computer you should carefully read the documentation in GCC*/install.
Assuming you have:
1. A working C compiler.
2. The usual tools: ar, awk, bash, bison, ld, make, patch, sed
3. The GPC and GCC tar.gz source in directory /usr/local/src
Then here's a cookbook recipe:
1. Unpack the two sources:
tar -xvzf gcc-2.95.2.tar.gz
tar -xvzf gpc-19991030.tar.gz
2. Since GCC recommends building gcc in a separate directory, lets
make one: we'll call it gcc-build.
mkdir gcc-build
3. Now we need to move GPC into GCC:
mv gpc/p gcc-2.95.2/gcc
4. Next is a patch to gcc:
cd gcc-2.95.2/gcc
patch -s -p1 < p/diffs/gcc-2.95.2.diff
5. Now GCC is ready to build several languages, including pascal.
If you want to know what languages,
grep language= */config-lang.in
will give you a list.
6. So let's go do it:
cd ../../gcc-build
../gcc-2.95.2/configure --enable-languages=pascal
make bootstrap-lean
With --enable-languages=pascal you get both GCC and GPC. The GCC
won't interfere with your default compiler because it is installed
in a different place. Without the --enable-languages option you get
ALL the languages GCC can build. Bootstrap-lean is recomended instead
of bootstrap because it removes files that are no longer needed.
That "make bootstrap-lean" will take some time. If you want to
know how much, you could
date > /time1 ; make bootstrap-lean ; date > /time2
On my 400mhz i586 with 128m ram, no swap, it took 24 min 34 sec.
7. If all went well you can now install it:
make install
That's it. You can find some interesting demos in
/usr/local/doc/gpc/demos
and you can find the units directory with
find /usr/local/lib -name units
3.0 After the Installation
**************************
3.1 What additional libraries should I have?
============================================
You will need certain additional libraries when you compile the units.
These can be found in the directory
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/libs
What follows is the contents of the README file found there:
In this directory, you can find the libraries used by some of GPC's
units. Currently, there are the following libraries:
- gmp:
Arithmetic for integers, rationals and real numbers with arbitrary
size and precision. Used by the GMP unit.
- rx:
Regular expression matching and substitution. Used by the RegEx
unit.
- ncurses, PDCurses:
Screen handling. Used by the CRT unit. Depending on your system,
you have the following choices:
Unix: You can compile terminal applications with ncurses and
applications that run in an X11 window with PDCurses (though
terminal applications can, of course, also run in an xterm under
X11). ncurses is used by default. If you want to use PDCurses
(a.k.a. XCurses), give the option `-DX11' when compiling CRT.
Dos with DJGPP and MS-Windows with mingw: Only PDCurses is
available and will be used by default.
MS-Windows with Cygwin: PDCurses and ncurses are available.
PDCurses is used by default. If you want to use ncurses, give the
option `-DUSE_NCURSES' when compiling CRT.
Other systems: Please see the `README's and installation
instructions of PDCurses and ncurses to find out which one(s) can
be built on your system. See the conditionals at the end of
crt.inc and crtc.h (and change them if necessary) on which library
is used by default.
The source code of the libraries is available in this directory.
Most libraries come with one or several patches which should be
applied before compiling them.
Binaries for some platforms are available in the `binary/<platform>'
subdirectories. If you compile the libraries for other platforms,
be invited to make the binaries available to us for distribution on
this FTP site.
There are also the following files:
- terminfo-linux.tar.gz
This is a patch to enable ncurses programs to make use of the
ability of Linux 2.2 and newer kernels to produce a block cursor
when needed. The present patch can be installed without
recompiling anything, just by copying some files into place. More
details can be found in the `README' file included in this
archive. The patch will not do any harm on older kernels. Please
note that *not* only on Linux machines it is useful to install the
patch. Installing them on any other machine will allow users who
telnet in from a Linux console to profit from the block cursor
capability. Besides, some Unix systems have installed older Linux
terminfo entries or none at all, so it's a good thing, anyway, to
give them a current version. The patch is included in the terminfo
database of ncurses 5.0, so if you install ncurses 5.0 (source or
binary), you don't need to get the patch separately. But you can
install it on a system with an older ncurses version if you don't
feel like upgrading ncurses altogether.
- tsort-2.9i.zip
A little utility (extracted from util-linux-2.9i, but not Linux
specific), needed for the configuration of the rx library. You
need it only if you compile rx yourself (and if it's not already
present on your system), not when using a rx binary.
In addition to the above libraries there is a unit which you can use
to interface Svalib. As of this writing the current release is
SvgaLib-GPC-20000216.tar.gz
and you can get it from
ftp://agnes.dida.physik.uni-essen.de/~nicola
3.2 Which components do I need to compile Pascal source code?
==============================================================
A complete Pascal compiler system should at least have:
1. The actual compiler, GPC. While there are some binaries available
you can build GPC yourself. You nee a working C compiler, some
tools: bash, ar, patch, make, the GCC source, and the GPC source.
2. An editor, Assembler, linker, librarian and friends.
3. A C library. If you have a working C compiler you already have this.
4. A debugger, if you want to debug your programs.
For most people, the GNU binutils and GNU debugger (gdb) are a good
choice, although some may prefer to use vendor specific tools.
3.3 How 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.
3.4 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 and most distributions.
* XWPE is an imitation of the Borland IDE, so users of Borland
Pascal may find it a good alternative.
* RHIDE. djgpp users should definately try RHIDE. The latest (beta)
release is compatible with GNU Pascal and allows stepping, tracing
and watching like Borland's IDE. RHIDE v0.6 beta can be downloaded
from:
http://www.tu-chemnitz.de/~sho/rho/rhide/rhide.html
* PENG. It's not free software, but it was written with GPC. It's
very similar to Borland's IDE, but with many extensions:
http://fjf.gnu.de/peng.html
3.6 Debugger?
==============
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.html
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/
4.0 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/djdev201.zip (C library)
v2gnu/bnu270b.zip (assembler, ....)
v2gnu/gdb416b.zip (debugger)
The rest is up to you; `make' (v2gnu/mak375b.zip) can be useful, The
latest RHIDE test release (an IDE with Borland-look) has support for
GNU Pascal, and can be downloaded from:
http://www.tu-chemnitz.de/~rho/rhidetest.html
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.
The GPC online documentation is in GNU info format; you need the info
reader (`txi390b.zip') to read it. To add the GPC documentation to the
info directory file, edit the `c:\gpc\info\dir' file, and locate this
section:
---------------------------------------------------------
* GCC: (gcc.inf).
The GNU C, C++, and Objective-C Compiler
* GDB: (gdb.inf).
The GNU Debugger (gdb and gdb-dpmi).
---------------------------------------------------------
To add GPC, change it to look like this:
---------------------------------------------------------
* GCC: (gcc.inf).
The GNU C, C++, and Objective-C Compiler
* GPC: (gpc.inf).
The GNU Pascal Compiler
* GDB: (gdb.inf).
The GNU Debugger (gdb and gdb-dpmi).
---------------------------------------------------------
Specific information for low-memory conditions and more can be found
in the djgpp FAQ and documentation.
I cannot read the info pages!
=============================
To read the info pages, you need the `info' program from
`txi390b.zip'.
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 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
There's also a GPC assembler tutorial at
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib/gpcasm.zip
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+}
{`Byte' and `Word' are built-in, and `ShortInt' is 'short' in C.}
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.
5.0 (reserved)
***************
6.0 STRINGS
***********
What's this confusion about strings?
====================================
Turbo Pascal strings have a length byte in front. Since a byte has the
range 0 - 255, this limits a string to 255 characters. However, the
Pascal string schema, as defined in section 6.4.3.3.3 of the ISO-10206:
1990 Extended Pascal standard, is a schema record:
type
String (Capacity : integer) = record
Length : 0 .. Capacity;
String : packed array [1 .. Capacity + 1] of Char
end;
The `+ 1' is a GPC extension to make it feasible to automatically
add the #0 terminator when passing or assigning them to CStrings. Thus
at the expense of a little added complexity ( must declare capacity,
don't use GetMem, and the additional space requiremnent ) you can now
have very long strings.
The following Q&A is also about strings:
========================================
Q: Should the different variants in a variant record overlay in the same
memory? Previous Pascals I have used have guaranteed this, and I've got
low-level code that relies on this. The variants are not the same
length, and they are intended not to be.
A: No, this is intentional so that the discriminants are not overwritten,
and they can be properly initialized in the first place. Consider:
record
case Boolean of
False: (s1 : String (42));
True: (s2 : String (99));
end;
If the strings would overlay, in particular their disriminants would
occupy the same place in memory. How should it be initialized?
Either way, it would be wrong for at least one of the variants...
So, after a discussion in comp.lang.pascal.ansi-iso where this topic
came up concerning file variables (which also require some automatic
initialization and finalization), we decided to do this in GPC for
all types with automatic initialization and finalization (currently
files and schemata, in the future this might also be Delphi
compatible classes and user-defined initialized and finalized
types), since the standard does not guarantee variants to overlay,
anyway...
There are two ways in GPC to get guaranteed overlaying (both
non-standard, of course, since the standard does not assume anything
about internal representations; both BP compatible), `absolute'
declarations and variable type casts. E.g., in order to overlay a
byte array to a variable v:
var
b: array [1 .. SizeOf (v)] of Byte absolute v;
or
type
t = array [1 .. SizeOf (v)] of Byte;
then `t (v)' can be used as a byte array overlayed to v.
Q: In standard pascal you expect ic[1] to align
with the first character position of s and thus one character to the left
is the length of s. Thus ic[0] is the length of s. True?
A: This holds for UCSD/BP strings (which GPC does not yet implement,
but that's planned). The only strings Standard Pascal knows are
arrays of char without any length value.
Q: Two different kinds of strings with the same name - string - does
make a bit of confusion. Perhaps the oldstyle strings could be renamed
"short string" ?
A: When we implement the short strings, we'll have to do such a
distinction. Our current planning goes like this:
string (n): string schema (EP compatible)
string [n]: short string (UCSD/BP compatible, where n must be <= 255)
string: dependent on flags, by default undiscriminated schema, but
in BP mode (or with a special switch) short string of capacity 255
(UCSD/BP compatible).
---- Frank
Q: So when will these short strings be available?
A: It's been planned for over a year. The delay has been caused by more
pressing problems.
What about C strings?
=====================
A C string (`char *') is an array of char, terminated with a
`NULL' char.
C library functions require C, not Pascal style string arguments.
However, Pascal style strings are automatically converted to C style
strings when passed to a routine that expects C style strings. This
works only if the routine reads from the string, not if it modifies it.
E.g., this is how you access the `system()' call in your C library
(which is not necessary any more, since `Execute' is already built-in):
---------------------------------------------------------
program SysCall;
function system(name : CString): integer; C;
var
result : integer;
begin
result := system ('ls -l');
writeln('system() call returned : ', result);
end.
---------------------------------------------------------
There may be other ways to do the same thing; you could use a
type `PChar' instead of `CString' and replace all references to
`CString' with `PChar'. `PChar' is predefined now (though we recommend
`CString' because it makes it clearer that we're talking about some
kind of string rather than a single character), and a lot of library
routines in Pascal for many applications (in the GPC unit and some
other units) have been written (see above)...
type
PChar = ^char;
Do *NOT* pass a "C" style string as a var-argument if the C prototype
says `const char *' or you will get a coredump.
6.0 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)gnu.de>. 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.
Also, the mailing list archives are a good place to look.
The URL is
http://www.gnu.de/archive/wilma.cgi/gpc
and
http://www.gnu.de/archive/wilma.cgi/gpc-announce
respectively. Now the pages also come in gpc signature colors. :-)
Note:
Currently, the search option is working fine. If you find it broken,
please email me at <anja(a)drewitz.de>. Please don't mail a copy to the
gpc list because I let procmail move all mails with To: gpc... and
Cc: gpc... to a separate folder and would not see your mail for a
long time.
--- Anja
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)gnu.de> 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)gnu.de> (NOT <gpc(a)gnu.de> !) with your request to be added
to the list.
How to unsubscribe from the mailing list
========================================
To leave the mailing list, send a message to <gpc-request(a)gnu.de>.
7.0 Miscellaneous
*****************
I want to contribute; where do I start?
=======================================
If you want to contribute, please write to the mailing list.
Where is the GNU Pascal FTP site? WWW?
======================================
The master FTP site for GNU Pascal is `agnes.dida.physic.uni-essen.de'.
GNU Pascal related files can be found in:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal
ftp://agnes.dida.physik.uni-esssen.de/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/gnu-pascal/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
Also, we have a homepage on the web:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/
Or shorter: http://home.pages.de/~GNU-Pascal/
---Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
About this FAQ.
===============
Original Maintainer: J.J. van der Heijden
<j.j.vanderheijden(a)student.utwente.nl>
Current Maintainer: Russ Whitaker <russwhit(a)mind.net>
This is the second 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).
Many people have contributed to this FAQ, only some of them are
acknowledged above. Much of the info in, and inspiration for this
FAQ list was taken from the gpc mailing list traffic, so you may have
(unbeknownst to you) contributed to this list.
Russ Whitaker wrote:
> Suggestion:
>
> define (all lower case letters) case insensitive
>
> Define (One or more upper case) case sensitive
I don't like this very much, I'm afraid. The other GPC directives
are case-insensitive, so I think `$define' should also be. (Besides,
it wouldn't be BP compatible...)
If there are no objections, I'm implementing:
Case insensitive:
{$define}
{$cidefine}
--cidefine
Case sensitive:
{$csdefine}
-D
--define
--csdefine
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
Russ Whitaker wrote:
> At long last here's vers 3 of the proposed FAQ
A few more typos:
compatable -> compatible
proir -> prior
kernal -> kernel
nee -> need
> and you can find the units directory with
> find /usr/local/lib -name units
Better:
and you can find the units directory with
gpc --print-file-name=units
after installation. If this doesn't give the correct directory
(or just says `units'), your installation is not quite right yet.
> flags : short;
This should be ShortInt.
> 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.
I'm wondering if we should suggest c.l.p.b at all. Is anyone
monitoring it for GPC related questions regularly? (I'm not reading
it anymore because of the high noise/signal ratio...)
Also, the new gpc-doc mailing list could be mentioned here. It's
still in the starting phase, but it will be the place for
documentation related discussions (such as this FAQ :-).
The last two changes apply to the upcoming release, due to some
recent changes:
> - A few unportable routines are not supported in the Dos unit (see
> the comments there). I think there's an older, unportable, Dos
> unit which supports them (or else it's easy to write one) if you
> really need those routines...
- A few unportable routines in the Dos unit are only supported
under DJGPP if `__BP_UNPORTABLE_ROUTINES__' is defined (i.e.,
when compiling with `-D__BP_UNPORTABLE_ROUTINES__').
> Then, add this to your `djgpp.env' file:
>
> ---------------------------------------------------------
> [gpc-cpp]
We renamed the preprocessor to gpcpp, so this line should read then:
[gpcpp]
When the FAQ is complete so far, let us know so we can include it
into the upcoming release distribution.
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html