Hi
This is always the most difficult part!
I am porting a very old Pascal program written originally in Prospero Pro-Pascal and I want to use a (relatively) platform independent compiler. Hence gpc.
So a few questions - I have already searched in the info pages (aka the 400+ page manual) and found the answers to some of my questions but:
1 A simple program like:
program t(Input,Output); var s:string[20]; begin read(s); writeln(s); end.
when compiled (and it works) still gives a message:
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/libgpc.a(randfile.o): In function `do_seek': /home/elug/pascal-wochenende-20000729/gcc-2.95.2/gcc/p/rts/randfile.c:327: the `llseek' function may be dangerous; use `lseek64' instead.
I may be running this at the weekend (RH 6.2 but gpc --version gives 2.95.2 19991024 (release) rather than anything like 20000729) but is this possibly an installation problem?
2 Is there a way of taking the command line arguments into a program? eg for a program foo.pas that compiles to a.out, I want to access argument 1 as 'something' in:
./a.out something
Is the whole command line available (like $0)?
I saw the demo getopt but when I tried to compile this, I was told that it couldn't find GPC (from uses GPC). Does this mean that I haven't installed it properly? gpc is in the default place (/usr/local/bin/gpc etc)
Hope my questions are clear
TIA
John
j.logsdon@lancaster.ac.uk wrote:
1 A simple program like:
program t(Input,Output); var s:string[20]; begin read(s); writeln(s); end.
when compiled (and it works) still gives a message:
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/libgpc.a(randfile.o): In function `do_seek': /home/elug/pascal-wochenende-20000729/gcc-2.95.2/gcc/p/rts/randfile.c:327: the `llseek' function may be dangerous; use `lseek64' instead.
I may be running this at the weekend (RH 6.2 but gpc --version gives 2.95.2 19991024 (release) rather than anything like 20000729) but is this possibly an installation problem?
This problem was fixed ~ Sep 13. If the warning occurs with a newer release, please report it.
Otherwise, you can ignore the warning unless you plan to work with files > 2GB on a 32 bit system.
2 Is there a way of taking the command line arguments into a program? eg for a program foo.pas that compiles to a.out, I want to access argument 1 as 'something' in:
./a.out something
Is the whole command line available (like $0)?
Under Unix, there's no such thing as the "whole command line" as under Dos, because the shell breaks it up into "words", does filename globbing etc. You can access the arguments with ParamCount and ParamStr (see the example in the manual reference under "ParamCount"). In the example above, ParamStr (1) will contain "something". GetOpt is a more comfortable way to parse typical options. So often, you will want to use GetOpt for the options, and ParamStr for the remaining arguments (file names etc.). GetOptDemo does this as well.
ParamStr (0), BTW, contains the name the program was invoked as (like $0 does in shell scripts).
I saw the demo getopt but when I tried to compile this, I was told that it couldn't find GPC (from uses GPC). Does this mean that I haven't installed it properly? gpc is in the default place (/usr/local/bin/gpc etc)
Please give the `--automake' switch when using any units. If it still doesn't work, it's probably a slight installation problem -- please report the full error message and the output of running `gpc --print-file-name=units'.
Frank
I am trying to access the available heap memory and there is an external function MemAvail - or is it an external integer?
While it is clearly not a Good Thing to use this on a multi-programmed system like Linux, I am building a cross-platform program that will also be run on Windroze. I note that MemAvail and MaxAvail will probably return the same on an MS platform but that's for the future ...
A very simple program like:
program testmem; function MemAvail:integer;external; begin writeln('Memory available is ',MemAvail:16); end.
responds with an undefined reference for Memavail.
What is the idiots way round this?
TIA
John
On 24 Oct 2000, at 16:24, j.logsdon@lancaster.ac.uk wrote:
I am trying to access the available heap memory and there is an external function MemAvail - or is it an external integer?
It is a function in the 'system' unit (which is not USEd by default).
While it is clearly not a Good Thing to use this on a multi-programmed system like Linux, I am building a cross-platform program that will also be run on Windroze. I note that MemAvail and MaxAvail will probably return the same on an MS platform
Yes, it will. There is no way round it.
A very simple program like:
program testmem; function MemAvail:integer;external; begin writeln('Memory available is ',MemAvail:16); end.
responds with an undefined reference for Memavail.
What is the idiots way round this?
program testmem;
USES System; // <<---- this is the magic! begin writeln('Memory available is ',MemAvail:16); end.
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Email: African_Chief@bigfoot.com Author of Chief's Installer Pro v5.23 for Win32 http://www.bigfoot.com/~African_Chief/chief32.htm
I am trying to understand why something I dug out of BP manual won't work in OOP and notice that there are various pointers to programs about bugs in the manual (eg chief39.pas, etc).
Can someone point me to where I can pick these up and the detailed description?
TIA
John
j.logsdon@lancaster.ac.uk wrote:
I am trying to understand why something I dug out of BP manual won't work in OOP and notice that there are various pointers to programs about bugs in the manual (eg chief39.pas, etc).
Can someone point me to where I can pick these up and the detailed description?
These test programs are part of GPC source distributions and the CVS archive (both contain the same things). Please see the homepage (http://home.pages.de/~GNU-Pascal/) for downloads.
More detailed descriptions than the To-Do list and the test programs themselves are not always available. Someof the entries in the To-Do list mention Message-IDs referring to postings on this mailing list with problem descriptions. Pointers to the mailing list archives are also on the homepage (under "Support").
Frank
Hi
Are there any layout or analysis tools tuned for GNU Pascal. In particular has anyone implemented an xref tool or perhaps something more up to date?
John
Maybe I am using a slightly old version (2.95.2 19991024 (release)) but the following little program indicates there is something awry with the upper limits of cardinals.
At least cardinal(32) and cardinal(64) should be able to calculate up to 4294967296 and 18446744073709551616 respectively. Note if I try and assign these directly within the program, the program doesn't compile with errors:
constant out of range
for the 32 bit case and
value does not fit in longest integer type
for the 64 bit case.
Cardinals limited by fewer bits (eg 20 and 24 but non-boundary anyway) should give 0 or overflow but in fact they all return 2^n in the calculations, even there n is greater than the nominal maximum but I have not used a packed variable.
John
program testnumb; type c32=cardinal(32); c20=cardinal(20); c24=cardinal(24); c64=cardinal(64); var i,ii:c32; j:c20; jj:c24; jjj:c20; k,kk:c64; l:byte; begin i:=1;ii:=1;j:=1;jj:=1;jjj:=1;k:=1;kk:=1; for l:=1 to 31 do i:=i*2; for l:=1 to 32 do ii:=ii*2; for l:=1 to 20 do j:=j*2; for l:=1 to 22 do jj:=jj*2; for l:=1 to 24 do jjj:=jjj*2; for l:=1 to 63 do k:=k*2; for l:=1 to 64 do kk:=kk*2; writeln(i); writeln(ii); writeln(j); writeln(jj); writeln(jjj); writeln(k); writeln(kk); end.
j.logsdon@lancaster.ac.uk wrote:
Maybe I am using a slightly old version (2.95.2 19991024 (release)) but the following little program indicates there is something awry with the upper limits of cardinals.
At least cardinal(32) and cardinal(64) should be able to calculate up to 4294967296 and 18446744073709551616 respectively. Note if I try and assign these directly within the program, the program doesn't compile with errors:
constant out of range
for the 32 bit case and
value does not fit in longest integer type
for the 64 bit case.
Well, the ranges are 0 .. 2^n-1, so these numbers are just a little too big.
Cardinals limited by fewer bits (eg 20 and 24 but non-boundary anyway) should give 0 or overflow but in fact they all return 2^n in the calculations, even there n is greater than the nominal maximum but I have not used a packed variable.
Yes, they should overflow. Since GPC doesn't support range/overflow checking yet, the result is more or less undefined. Sorry...
Frank
Hi
Is there somewhere a version of pretty print and xref tuned for GNU Pascal? Emacs helps somewhat but I would prefer a pretty print that I could configure in particular. Is it available in the sources? I am using the binary at the moment.
John
I am trying to use the ddd debugger (gdb underneath). I can't see the actual variables since it reports a message:
No symbol "whatever-it-is" in current context
for anything. I realise I am using rather an old version - 2.95.2 19991024 (release) on RH6.2 Linux - that was the latest RPM for RH available at the time but perhaps this is more to do with ddd/gdb than gpc.
There is a message in the info
* The GNU debugger (GDB) does not yet understand Pascal syntax and types; you have to use C syntax when debugging Pascal programs with GDB.
but I am just looking for the value of the variable. ddd certainly steps through the program OK, so it is understanding something. The compilation is just with flag -g.
Is there a way of revealing all?
TIA
John
j.logsdon@lancaster.ac.uk a écrit :
I am trying to use the ddd debugger (gdb underneath). I can't see the actual variables since it reports a message:
No symbol "whatever-it-is" in current context
Did you take into account that internally (i.e. what the debugger sees) Pascal Variables Have All First Letter Capitalized And The Remaining Ones Lower Cases, even if you use a different capitalization in your program (for the user pascal is case insensitive, but gdb is a C debugger, case sensitive) ?
Hi John! j.logsdon@lancaster.ac.uk wrote:
- The GNU debugger (GDB) does not yet understand Pascal syntax and types; you have to use C syntax when debugging Pascal programs with GDB.
When the DDD runs type at the command line windows ( the little window with the `(gdb)'-prompt ) the following command: set language modula-2 In the status-bar of the DDD appears: Current language: pascal/modula That's all, so you can use the full power of the gdb with pascal source-code and the graphical front-end :-)! (gdb works fine with emacs too)
Code fragement: Var i:Integer; MyReal:Real;
To display the variables above use the menus or type at the command line. At the command type the following: display I display Myreal
You see, the first/only character MUST be upper case and the rest in lower case.
Thorsten