3.10. Compiling Pascal Programs

Pascal programs can be converted to C language programs and then compiled in the usual way. The p2c command on Linux does this for you. Consider the following Pascal program hello.pas.

(* Program to demonstrate Pascal compilation *)
program Hello ;
begin
   writeln ('Hello world')
end.

The following command will create a file hello.c which is the equivalent C version of the hello.pas program.

[rr@conformix 4]$ p2c hello.pas
Hello

Translation completed.
[rr@conformix 4]$

The output hello.c file is shown below:

 /* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "hello.pas" */ /* Program to demonstrate Pascal compilation */ #include <p2c/p2c.h> main(argc, argv) int argc; Char ...

Get Linux Development Platform: Configuring, Using, and Maintaining a Complete Programming Environment, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.