Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
XENIX Programming cc: C Compiler To create an assembly language listing, give the name of the desired source file. For example, the command cc -5 add.c creates an assembly language listing file named add.s and the command cc -L mult.c creates a listing file named mult.L. Note that both the -S and -L options suppress subsequent compilation of the source file; they imply the -c option. Thus, no program file is creat ed and no linking is performed. Another use of the -S option is to create an assembly language source file that may be optimized by hand and later submitted to masm for translation. Although this method can be useful, optimizing should be left to the compiler whenever possible. The -S and -L options apply to source files only; the compiler cannot create an assembly language listing file from an existing object file. Furthermore, the options in the command line must appear before the names of the files for which the assem bly listings are to be saved. Profiling a Program You can examine the flow of execution of a program by adding "profiling" code to the program with the -p option. The profiling code automatically keeps a record of the number of times program functions are called during execution of the program. This record is written to the mon.out file and can be examined with the prof command. For example, the command cc -p main.c adds profiling code to the program created from the source file main.c. The profiling code automatically calls the monitor function, which creates the mon.out file at normal termination of the program. The prof command is described in Appendix B, "Programm ing Commands." The monitor function is described in "System Functions" in the XENIX 286 C Library Guide. The -p option must be given in any command line that links object files containing profiling code. For example, if the command cc -c -p f1.c f2.c was used to create the object files fl.o and f2.o, then the command cc -p f1.o f2.o must be used to create an executable program from these files. 2-11
cc: C Compiler XENIX Programming Controlling the C Preprocessor The cc command provides a number of options to control the operation of the C preprocessor. These options can define macros, modify the new search path to include files, and suppress subsequent compilation of the preprocessed source file. Defining a Macro You can define the value or meaning of a macro used in a source file by using the -D (for "define") option. The -D option assigns a value to a macro when you invoke the compiler and is useful if you have used if, ifdef, and ifndef directives in your source files. The option has the form -Dname'[ =string ] where name is the name of the macro and string is its value or meaning. If no string is given, the macro is defined and its value is set to 1. For example, the command cc -DNEED = 2 main.c sets the macro "NEED" to the value "2". This has the same effect as having the directive #define NEED 2 in the source file. The command compiles the source file main.c, replacing every occurrence of "NEED" with "2". The -D option is especially useful with the ifdef directive. You can use the option to determine which statements in the source are to be compiled. For example, suppose a source file, main.c, contains the directive #ifdef NEED but no explicit define directive for the macro "NEED". Then all statements controlled by the ifdef directive would be compiled only if you supply an explicit definition of "NEED" by using -D. For example, the command cc -DNEED main.c is sufficient to compile all statements controlled by the ifdef directive, while the com mand cc main.c causes those statements to be ignored. 2-1 2
- Page 1 and 2: 0 • • •
- Page 3 and 4: The information in this document is
- Page 5 and 6: Table of Contents CONTENTS Compiler
- Page 7 and 8: Table of Contents CONTENTS Using Ot
- Page 9 and 10: Table of Contents CONTENTS Assemble
- Page 11 and 12: Table of Contents CONTENTS CHAPTER
- Page 13 and 14: Table of Contents TABLES TABLE TITL
- Page 15 and 16: Introduction XENIX Programming 10.
- Page 17 and 18: cc: C Compiler XENIX Programming Cr
- Page 19 and 20: cc: C Compiler XENIX Programming Th
- Page 21 and 22: cc: C Compiler XENIX Programming Th
- Page 23 and 24: cc: C Compiler XENIX Programming Cr
- Page 25: cc: C Compiler XENIX Programming Th
- Page 29 and 30: cc: C Compiler XENIX Programming Sa
- Page 31 and 32: cc: C Compiler XENIX Programming Us
- Page 33 and 34: cc: C Compiler XENIX Programming Wh
- Page 35 and 36: cc: C Compiler XENIX Programming Co
- Page 37 and 38: cc: C Compiler XENIX Programming d
- Page 39 and 40: cc: C Compiler XENIX Programming Se
- Page 41 and 42: lint: C Program Checker XENIX Progr
- Page 43 and 44: lint: C Program Checker XENIX Progr
- Page 45 and 46: lint: C Program Checker XENIX Progr
- Page 47 and 48: lint: C Program Checker XENIX Progr
- Page 49 and 50: lint: C Program Checker XENIX Progr
- Page 51 and 52: lint: C Program Checker XENIX Progr
- Page 53 and 54: make: Program Maintainer XENIX Prog
- Page 55 and 56: make: Program Maintainer XENIX Prog
- Page 57 and 58: make: Program Maintainer XENIX Prog
- Page 59 and 60: make: Program Maintainer XENIX Prog
- Page 61 and 62: make: Program Maintainer XENIX Prog
- Page 63 and 64: make: Program Maintainer XENIX Prog
- Page 65 and 66: make: Program Maintainer print: $(F
- Page 67 and 68: SCCS: Source Code Control System XE
- Page 69 and 70: SCCS: Source Code Control System XE
- Page 71 and 72: SCCS: Source Code Control System XE
- Page 73 and 74: SCCS: Source Code Control System XE
- Page 75 and 76: SCCS: Source Code Control System XE
cc: C Compiler <strong>XENIX</strong> Programming<br />
Controlling the C Preprocessor<br />
The cc command provides a number of options to control the operation of the C<br />
preprocessor. These options can define macros, modify the new search path to include<br />
files, and suppress subsequent compilation of the preprocessed source file.<br />
Defining a Macro<br />
You can define the value or meaning of a macro used in a source file by using the -D<br />
(for "define") option. The -D option assigns a value to a macro when you invoke the<br />
compiler and is useful if you have used if, ifdef, and ifndef directives in your source<br />
files.<br />
The option has the form<br />
-Dname'[ =string ]<br />
where name is the name of the macro and string is its value or meaning. If no string is<br />
given, the macro is defined and its value is set to 1. For example, the command<br />
cc -DNEED = 2 main.c<br />
sets the macro "NEED" to the value "2". This has the same effect as having the<br />
directive<br />
#define NEED 2<br />
in the source file. The command compiles the source file main.c, replacing every<br />
occurrence of "NEED" with "2".<br />
The -D option is especially useful with the ifdef directive. You can use the option to<br />
determine which statements in the source are to be compiled. For example, suppose a<br />
source file, main.c, contains the directive<br />
#ifdef NEED<br />
but no explicit define directive for the macro "NEED". Then all statements controlled<br />
by the ifdef directive would be compiled only if you supply an explicit definition of<br />
"NEED" by using -D. For example, the command<br />
cc -DNEED main.c<br />
is sufficient to compile all statements controlled by the ifdef directive, while the<br />
com mand<br />
cc main.c<br />
causes those statements to be ignored.<br />
2-1 2