Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.stsci.edu/ftp/documents/system-docs/vms-guide/html/VUG_45.html
Дата изменения: Wed Nov 1 17:38:26 1995 Дата индексирования: Sun Dec 23 18:30:37 2007 Кодировка: Поисковые слова: р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п |
OBJ
.
EXE
.
RECALC.FOR
, then you would use the following commands to compile, link, and execute the program:
$ FORT RECALC $ LINK RECALC $ RUN RECALCWhen you write your programs, your source files should always have a file type that identifies the programming language being used. This makes it easier to invoke the compiler because you do not need to specify the file type. The following table lists the file types used under VMS.
The debugger is used by specifying the
The C language has no native input or output facilities; these are provided by a run-time library. Before you can use the C compiler under VMS, you must set up the necessary logicals. To do this you can put the following line in your
Once you create a Pascal source file--using your favorite editor--you need to run the compiler, link the object code, and run the executable image.
The Pascal compiler is run by typing the
The MACRO compiler is run by typing the
Generated with CERN WebMaker
Table 7.1: Source File Types
A debugging program is available that lets you control the execution of programs and monitor their progress as they execute. If any error occurs during execution, the program remains in the debugger letting you examine the values of variables and other features in order to identify errors. The debugger can also be used in step-through mode, which lets you check the program's status after each line of code is executed. /DEBUG
option during both the compile and link steps. (An example of using the /DEBUG
option is provided in the description of FORTRAN on page 127). After successfully debugging a program, you should recompile and relink it without the /DEBUG
option so that the program will run more efficiently.*1 C
C was developed by AT&T Bell Laboratories under the Unix operating system but was designed to be portable across different systems. The language is described in detail in numerous books. One of the most widely used, The C Programming Language, by Brian Kernighan and Dennis Ritchie, is available in the STScI library.LOGIN.COM
file (or you can type it in during every session in which you plan to compile C programs):
$ DEFINE LNK$LIBRARY SYS$LIBRARY:VAXCRTL
Writing and running a C program is a four-step process:
The following example shows how to run a program called CALCULATE
. Note that in this example, file types are used. File types are optional, for example, the command $
link
calculate
would be the same as $
link
calculate.obj
.
$ DEFINE LNK$LIBRARY SYS$LIBRARY:VAXCRTL
$ CC CALCULATE.C
$ LINK CALCULATE.OBJ
$ RUN CALCULATE.EXE
A discussion of the features or syntax of the C language is beyond the scope of this manual; you should refer to the Kernighan and Ritchie book (or another text) for that information. Online help is also available. Type HELP
CC
at the system prompt. The following example shows an extremely simple C program (but one that works).
#include stdio.h
main()
{
int answer;
answer = 2 +3 ;
printf("The answer is %d.", answer);
}
C++
C++ is an object-oriented C compiler. Two implementations are available at the Institute: Digital's version of C++, which is invoked by the cxx
command, and GNU's version, called G++, which is invoked by the gxx
command. The C++ compilers may not yet be available on all systems at the Institute. A reference book, The C++ Programming Language, by Bjarne Stroustrup, is available in the STScI Library. FORTRAN
DECFortran is available on most systems at STScI. Compiling, linking, and running FORTRAN programs is done in exactly the same way as for C. FORTRAN programs should usually have a file type of .FOR
. The following example shows how a FORTRAN program file called COMPUTE.FOR
would be compiled, linked, and run, with the optional debugger specified:
$ FORTRAN/DEBUG/NOOPTIMIZE COMPUTE
$ LINK/DEBUG COMPUTE
$ RUN COMPUTE
Pascal
The Pascal language is a structured language with flexible variable types and user-definable procedures and functions. Pascal source files should all have a file type of .PAS
.PASCAL
command. The following shows a sample Pascal run.
$ PASCAL COMPUTE.PAS
$ LINK COMPUTE
$ RUN COMPUTE
MACRO
MACRO is used in the same way as any of the previously-described languages. If you are interested in the MACRO language, you should see the VAX MACRO and Instruction Set Reference Manual. Users create a source file of MACRO statements and then compile, link, and run, the file.MACRO
command. The following shows a sample run (using the VAX MACRO assembler).
$ MACRO FILE.MAR
$ LINK FILE
$ RUN FILE
There are two MACRO compilers: one for VAX systems and one for Alpha (AXP) systems. The VAX MACRO assembler (MACRO-32) is used by default on VAX systems and can be used from an Alpha to compile VAX assembly language source. If you are using an AXP host, you can use the /ALPHA
qualifier when invoking the MACRO compiler to use the MACRO-64 assembler.