Russ Whitaker wrote:
attached is a rough draft of a FAQ. Will add about the Solaris 8 binaries. Any additions, corrections, comments?
OK, here are some...
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.
This has changed a lot. Almost all BP language features are supported now. Notable exceptions are the string format (as discussed below), or the `Mem' and `Port' pseudo arrays, though replacement 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 compatible Graph unit exists, but is distributed separately 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...
When I build `libgpc.a', `rt0.c' says: SIGXCPU undefined (and more)
I'm adding an autoconf test to overcome this problem, so I think you can remove the item after the next release.
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 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/~rho/rhidetest.html
The URL has changed to:
http://www.tu-chemnitz.de/~sho/rho/rhide/rhide.html
Also, I'd like to plug my own IDE, PENG. It's not free software, but it was written with GPC. It's also very similar to Borland's IDE, but with many extensions:
Do you have a binary for me?
Currently, we have binaries for these platforms:
i486-linux (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
New binaries may have been added after the release of this FAQ.
You might want to update the list by looking at the FTP directory beta/binary on agnes.
3.0 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.
GPC knows the type `Word' (and, for that matter, equivalent built-in types for all integer types in C). `__unsigned__' is considered obsolete and will probably removed soon, so using the built-in `Word' (or `Cardinal' which is the same) is recommended (see the subsection `Integer Types' in the GPC manual).
Also, as Peter mentioned, GPC by now provides routines for many libc functions. Most of them are declared in the GPC unit (see the section `Run time library' in the chapter `Programming' in the GPC manual for complete declarations). `Sleep' is one of them, and using the one from the GPC unit is recommended, because it's more portable.
How do I build/use a shared library?
(topic under construction)
Using them is easy: Just add the appropriate `-lfoo' option to the command line, or (more recommended) a `{$L foo}' compiler directive (where `foo' is the name of the library) into the program or a unit. This will use a shared library by default, and a static one if a shared library is not found or the command line option `-static' is given.
Creating a shared library currently works like in GCC, e.g. by linking the object files with `-shared'. You will have to take care about the interfaces yourself, since GPI files are not handled, and you might have to explicitly call any unit/module initializers.
There is support for building the GPC runtime library (libgpc) dynamically, by configuring the RTS (not the compiler!) with `--with-shared', which can reduce the size of executables dramatically, but since it makes the executables dependent on the shared library version and the runtime library is changing fast, this is currently considered "on your own risk". Don't do it if you intend to distribute your binaries.
Note that some platforms, e.g. DJGPP, don't support shared libs at all.
However, 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;
Actually it's 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.
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?
Better add a "Q:" here, otherwise careless readers might take the "standard pascal" bit as a true statement...
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!
`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)...
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 think that's obsolete. :-)
A guide is available which was written by Brennan Mr. Wacko Underwood brennan@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
type word = __unsigned__ integer; short = __short__ integer; byte = __byte__ integer;
See above. (`Byte' and `Word' are built-in, and `ShortInt' is `short' in C.)
Bugs are best reported to the GPC mailinglist gpc@hut.fi.
You can send a message to the GPC mailing list by sending email to the list address gpc@hut.fi as if it were a person.
You can join the mailing list by sending a message to gpc-request@hut.fi (NOT gpc@hut.fi !) with your request to be added to the list. Maintenance is done by hand, so some delay is possible.
To leave the mailing list, send a message to gpc-request@hut.fi.
s/hut.fi/gnu.de/ :-)
Maintenance is automatic now.
7.0 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 is hopelessly outdated (and I think has been removed from the distribution now). For now, if you want to contribute, please write to the mailing list.
The master FTP site for GNU Pascal is `kampi.hut.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/gnu-pascal/
agnes is now the master FTP site rather than kampi.
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