C Compiler

From VSI OpenVMS Wiki
Jump to: navigation, search

The C Compiler is the software that compiles code written in C into object files.

Syntax

CC file-spec,...  +library-file-spec/LIBRARY...

Qualifiers

  • /ACCEPT(option[,...]) allows the compiler to accept C language syntax that it might not normally accept.
Option Description
[NO]C99_KEYWORDS Controls whether or not the C99 Standard keywords inline and restrict (which are are in the C89 namespace for user identifiers) are accepted without double leading underscores. The spelling with two leading underscores (__inline, __restrict) is in the namespace reserved to the compiler implementation and is always recognized as a keyword regardless of this option. In /STANDARD=RELAXED mode, the default is C99_KEYWORDS. In all other compiler modes, the default is NOC99_KEYWORDS.
[NO]GCCINLINE The gcc compiler implements an inline function qualifier for functions with external linkage that gives similar capabilites as the C9x extern inline feature for functions, but the usage details are somewhat different: the combination of extern and inline keywords makes an inline definition, instead of the exlusive use of the inline keyword without the extern keyword. This option controls which variation of the feature is implemented. In all compiler modes, the default is NOGCCINLINE.
[NO]TRIGRAPHS Turns trigraph support on or off. In COMMON and VAXC compiler modes, trigraphs are disabled by default. In all other modes, they are enabled by default.
[NO]VAXC_KEYWORDS Controls whether or not the compiler recognizes the VAX C keywords (such as "readonly") regardless of the /STANDARD mode used.
[NO]RESTRICT_KEYWORD Controls whether or not the compiler recognizes the C9x standard restrict keyword regardless of the /STANDARD mode used. This only affects recognition of the spelling of the keyword as proposed for inclusion in the C9x standard. The spelling with two leading underscores, __restrict, is in the namespace reserved to the compiler implementation, and it is always recognized as a keyword regardless of this option. Note that [NO]RESTRICT_KEYWORD is a subset of [NO]C99_KEYWORDS. They have the same compiler-mode defaults.

The default values are based upon the settings of the /STANDARD qualifier:

  • For /STANDARD=RELAXED the default is: /ACCEPT=(VAXC_KEYWORDS,C99_KEYWORDS,NOGCCINLINE,TRIGRAPHS)
  • For /STANDARD=VAXC, the default is: /ACCEPT=(VAXC_KEYWORDS,NOC99_KEYWORDS,NOGCCINLINE,NOTRIGRAPHS)
  • For /STANDARD=COMMON, the default is: /ACCEPT=(NOVAXC_KEYWORDS,NOC99_KEYWORDS,NOGCCINLINE,NOTRIGRAPHS)
  • For /STANDARD=C99 or /STANDARD=LATEST, the default is: /ACCEPT=(NOVAXC_KEYWORDS,C99_KEYWORDS,NOGCCINLINE,TRIGRAPHS)
  • In all other modes, the default is: /ACCEPT=(NOVAXC_KEYWORDS,NOC99_KEYWORDS,NOGCCINLINE,TRIGRAPHS)
  • /[NO]ANALYSIS_DATA[=file-spec] controls whether the compiler generates a file of source code analysis information. The default file name is the file name of the primary source file; the default file type is .ANA. The default value is /NOANALYSIS_DATA.
  • /[NO]ANNOTATIONS[=(option,...)] controls whether or not the source listing file is annotated with indications of specific optimizations performed or, in some cases, not performed. These annotations can be helpful in understanding the optimization process. The default is /NOANNOTATIONS. Specifying /ANNOTATIONS with no keywords is the same as specifying /ANNOTATIONS=(ALL,NODETAIL).
    • ALL: Selects all annotations. This output can be quite verbose because it includes detailed output for all annotations. For more concise output for each kind of annotation, use /ANNOTATIONS=(ALL,NODETAIL), or just /ANNOTATIONS with no qualifier options.
    • [NO]CODE: annotates the machine-code listing with descriptions of special instructions used for prefetching, alignment, and so on. The /MACHINE_CODE qualifier must also be specified for /ANNOTATION=CODE to have any visible effect.
    • [NO]DETAIL: provides additional level of annotation detail, where available.
    • [NO]FEEDBACK: Indicates use of profile-directed feedback optimizations. Feedback optimizations are not implemented on OpenVMS systems, so this keyword has no visible effect.
    • [NO]INLINING: indicates where code for a called procedure was expanded inline.
    • [NO]LOOP_TRANSFORMS: Indicates optimizations such as loop reordering and code hoisting.
    • [NO]LOOP_UNROLLING: indicates where advanced loop nest optimizations have been applied to improve cache performance (unroll and jam, loop fusion, loop interchange, and so on).
    • [NO]PREFETCHING: indicates where special instructions were used to reduce memory latency.
    • [NO]SHRINKWRAPPING: indicates removal of code establishing routine context whenit is not needed.
    • [NO]SOFTWARE_PIPELINING: indicates where loops have been scheduled to hide functionalunit latency.
    • [NO]TAIL_CALLS: indicates an optimization where a call from routine A to Bcan be replaced by a jump.
    • [NO]TAIL_RECURSION: indicates an optimization that eliminates unnecessary routinecontext for a recursive call.
    • NONE: same as /NOANNOTATIONS.
  • /[NO]ANSI_ALIAS: directs the compiler to assume the ANSI C aliasing rules, thus giving it the freedom to generate better optimized code. The aliasing rules are explained in Section 3.3, paragraphs 20 and 25 of the ANSI C Standard. The default is /NOANSI_ALIAS for the /STANDARD=VAXC and /STANDARD=COMMON compiler modes. The default is /ANSI_ALIAS for all other modes.
  • /ARCHITECTURE=option: currently ignored for x86-64 systems but we expect to provide options to pass along to the LLVM code generator to select machine attributes
  • /ASSUME=(option[,...]): controls compiler assumptions.
Option Description
[NO]ACCURACY_SENSITIVE Specifies whether certain code transformations that affect floating-point operations are allowed. These changes may or

may not affect the accuracy of the program's results. If you specify NOACCURACY_SENSITIVE, the compiler is free to reorder floating-point operations, based on algebraic identities (inverses, associativity, and distribution). This allows the compiler to move divide operations outside of loops, improving performance. The default, ACCURACY_SENSITIVE, directs the compiler to use only certain scalar rules for calculations. This setting can prevent some optimization.

[NO]ALIGNED_OBJECTS Controls an optimization for dereferencing pointers. On OpenVMS Alpha systems, dereferencing a pointer to a longword- or quadword-aligned object is more efficient than dereferencing a pointer to a byte- or word-aligned object. Therefore, the compiler can generate more optimized code if it makes the assumption that a pointer object of an aligned pointer type does point to an aligned object. Since the compiler determines the alignment of the dereferenced object from the type of the pointer, and the program is allowed to compute a pointer that references an unaligned object (even though the pointer type indicates that it references an aligned object), the compiler must assume that the dereferenced object's alignment matches or exceeds the alignment indicated by the pointer type. The default, /ASSUME=ALIGNED_OBJECTS, allows the compiler to make such an assumption. With this assumption made, the compiler can generate more efficient code for pointer dereferences of aligned pointer types. To prevent the compiler from assuming the pointer type's alignment for objects that it points to, use the /ASSUME=NOALIGNED_OBJECTS qualifier.
[NO]CLEAN_PARAMETERS Controls compiler assumptions about short-integer formal parameters. The Alpha Calling Standard requires integers less than 64 bits long that are passed by value to have their upper bits either zeroed or sign-extended to make full 64-bit values. These are referred to as clean parameters. Some old code does not follow this convention. This can cause problems if the called program assumes that the caller followed the Calling Standard by passing only clean parameters. Specifying /ASSUME=NOCLEAN_PARAMETERS allows a program to be called by old code that might pass unclean integer parameters. It directs the compiler to generate run-time code to clean the short integers so they comply with the Calling Standard. The default is /ASSUME=CLEAN_PARAMETERS.
[NO]EXACT_CDD_OFFSETS Controls the alignment of Control Data Dictionary records. If /ASSUME=EXACT_CDD_OFFSETS is specified, the records input from the CDD are given the exact alignment (relative to the start of the record) specified by the CDD definition. This alignment is independent of the current compiler member-alignment setting. If /ASSUME=NOEXACT_CDD_OFFSETS is specified, the compiler may modify the offsets specified in a CDD record according to the current member-alignment setting. The default is /ASSUME=NOEXACT_CDD_OFFSETS.
[NO]POINTERS_TO_GLOBALS Controls whether or not the compiler can safely assume that global variables have not had their addresses taken in code that is not visible to the current compilation. The default, /ASSUME=POINTERS_TO_GLOBALS, assumes that global variables have had their addresses taken in separately compiled modules and that, in general, any pointer dereference could be accessing the same memory as any global variable. This is often a significant barrier to optimization. The /ANSI_ALIAS qualifier allows some resolution based on data type, but /ASSUME=NOPOINTER_TO_GLOBALS provides significant additional resolution and improved optimization in many cases.
[NO]WEAK_VOLATILE Affects the generation of code for assignments to objects that are less than or equal to 16 bits in size (for example: char, short) that have been declared as volatile. Specifying /ASSUME=WEAK_VOLATILE directs the compiler to generate code for volatile assignments to single bytes or words without using the load-locked store-conditional sequences that, in general, are required to assure volatile data integrity when direct byte or word memory-access instructions are not being used. This option is intended for use in special I/O hardware access situations, and should not generally be used. The default is /ASSUME=NOWEAK_VOLATILE, which uses interlocked instructions for sub-longword volatile accesses when byte or word instructions are not enabled.
[NO]WHOLE_PROGRAM Asserts to the compiler that except for "well-behaved library routines," the whole program consists only of the single object module being produced by this compilation. The optimizations enabled by /ASSUME=WHOLE_PROGRAM include all those enabled by /ASSUME=NOPOINTER_TO_GLOBALS, and possibly additional optimizations as well. The default is /ASSUME=NOWHOLE_PROGRAM.
[NO]WRITABLE_STRING_LITERALS Stores string constants in a writable psect. Otherwise, such constants will be placed in non-writable psect. For /STANDARD=VAXC or /STANDARD=COMMON, the default is /ASSUME=WRITABLE_STRING_LITERALS. For all other compiler modes, the default is /ASSUME=NOWRITABLE_STRING_LITERALS.
[NO]MATH_ERRNO Controls whether or not intrinsic code is generated for math functions that set the errno variable. The default is /ASSUME=MATH_ERRNO, which does not allow intrinsic code for such math functions to be generated, even if /OPTIMIZE=INTRINSICS is in effect. Their prototypes and call formats, however, are still checked.
[NO]HEADER_TYPE_DEFAULT Specifies whether the default file-type mechanism (.h) for header files is enabled (HEADER_TYPE_DEFAULT) or disabled (NOHEADER_TYPE_DEFAULT). The default is /ASSUME=HEADER_TYPE_DEFAULT.
  • /[NO]CHECK[=(option[,...])]: this qualifier is for use only as a debugging aid. It should not be used to build production code without carefully assessing its performance impact on the application in question for each platform on which the application runs. For example, the I64-only FP_MODE check can add significant overhead to every function in the compilation, even if the application uses little or no floating point.
    • /CHECK=NONE is equivalent to /NOCHECK
    • /CHECK=UNINITIALIZED_VARIABLES initializes all automatic variables to the value 0x7ff580057ff58005. This value is a double signaling NaN and, if used as a floating-point value in certain double operations, causes a floating-point trap if traps are enabled. Traps are not enabled if the program is compiled /FLOAT=IEEE and the /IEEE value is something other than FAST.
    • /CHECK=BOUNDS enables run-time checking of array bounds. Check HELP on CC for array-bounds processing rules.
    • /CHECK=POINTER_SIZE directs the compiler to check 32-bit pointer values to make sure they will fit in a 32-bit pointer. If such a value cannot be represented by a 32-bit pointer, the run-time code signals a range error (SS$_RANGEERR). Use /POINTER_SIZE option keywords (below) to determine the pointer-size checks you want made.
  • /COMMENTS: governs whether or not comments appear in preprocess output files and, if they are to appear, whether they appear themselves or are replaced by a single space.
    • /COMMENTS=SPACE (D) (ANSI89, RELAXED, and MIA compiler modes): specifies that a single space replaces the comment in the output file.
    • /NOCOMMENTS (D) (all other compiler modes)
    • /COMMENTS or /COMMENTS=AS_IS: Specifies that the comment appears in the output file.
  • /[NO]CROSS_REFERENCE: Specifies whether the compiler generates cross-references. If you specify /CROSS_REFERENCE, the compiler lists, for each variable referenced in the procedure, the line numbers of the lines on which the variable is referenced. You must use the /CROSS_REFERENCE qualifier with either the /SHOW=SYMBOLS or the /SHOW=BRIEF qualifiers. To obtain any type of listing, you must specify /LIST.
  • /[NO]DEBUG[=(option[,...])]: includes information in the object module for use by the OpenVMS Debugger. You can select the following options:
Option Description
ALL Includes all possible debugging information. On Alpha systems, /DEBUG=ALL is equivalent to /DEBUG=(TRACEBACK,SYMBOLS). On VAX systems, /DEBUG=ALL is equivalent to /DEBUG=(TRACEBACK,SYMBOLS,INLINE). Specifying /DEBUG with no options is equivalent to specifying /DEBUG=ALL. If the /DEBUG qualifier is not specified, the default is /DEBUG=(TRACEBACK,NOSYMBOLS).
NONE Excludes any debugging information.
NOSYMBOLS Suppresses generation of symbol table records.
SYMBOLS Generates symbol table records.
NOTRACEBACK Suppresses generation of traceback records.
TRACEBACK Generates traceback records.
  • /DECC: The /DECC qualifier is provided for compatibility with HP C on OpenVMS VAX systems. On OpenVMS Alpha systems, CC and CC/DECC are always equivalent.
  • /[NO]DEFINE=(identifier[=definition][,...]) performs the same function as the #define preprocessor directive. That is, /DEFINE defines a token string or macro to be substituted for every occurrence of a given identifier in the program. DCL converts all input to uppercase unless it is enclosed in quotation marks.
  • /[NO]DIAGNOSTICS[=file-spec] Creates a file containing compiler diagnostic messages. The default file extension for a diagnostics file is .DIA. The diagnostics file is used with the DEC Language-Sensitive Editor (LSE). To display a diagnostics file, enter the command REVIEW/FILE=file-spec while in LSE.
  • /ERROR_LIMIT[=number]
  • /EXTERN_MODEL=option
  • /[NO]FIRST_INCLUDE=(file[,...])
  • /FLOAT=option
  • /GRANULARITY
  • /IEEE_MODE=option
  • /[NO]INCLUDE_DIRECTORY=(pathname[,...])
  • /L_DOUBLE_SIZE=option
  • /LIBRARY
  • /[NO]LINE_DIRECTIVES
  • /[NO]LIST[=file-spec]
  • /[NO]MACHINE_CODE
  • /[NO]MEMBER_ALIGNMENT
  • /[NO]MMS_DEPENDENCIES[=(option[,option])]
  • /NAMES=(option1,option2)
  • /NESTED_INCLUDE_DIRECTORY[=option]
  • /[NO]OBJECT[=file-spec]
  • /[NO]OPTIMIZE[=option]
  • /PDSC_MASK=option
  • /[NO]PLUS_LIST_OPTIMIZE
  • /[NO]POINTER_SIZE=option
  • /PRECISION={SINGLE | DOUBLE}
  • /[NO]PREFIX_LIBRARY_ENTRIES
  • /[NO]PREPROCESS_ONLY[=filename]
  • /[NO]PROTOTYPE[=(option[,...])]
  • /PSECT_MODEL=[NO]MULTILANGUAGE
  • /REENTRANCY=option
  • /REPOSITORY=option
  • /ROUNDING_MODE=option
  • /[NO]SHARE_GLOBALS
  • /SHOW[=(option[,...])]
  • /[NO]STANDARD=(option)
  • /[NO]UNDEFINE=(identifier[,...])
  • /[NO]UNSIGNED_CHAR
  • /[NO]VERSION
  • /[NO]WARNINGS[=(option[,...])]

Includes

CC /INCLUDE_DIRECTORY qualifier provides similar functionality to the -I option of the cc command on DIGITAL UNIX systems: it allows you to specify additional places to search for include files. It can be one of the following:

  • OpenVMS file-spec to be used as a default file-spec to RMS file services:
/INCLUDE=DISK$:[directory]
  • UNIX style pathname in quotation marks
/INCLUDE=/sys
  • Empty string ("")
/INCLUDE=""

The interpretation depends on the format of the #include directive: whether it is is quotes or angle brackets:

#include "stdio.h"
#include <stdio.h>

Quoted includes

1. Look at the /NESTED qualifier on the CC command.

  • missing or /NESTED=INCLUDE: search the directory containing the source file with the #include directive
  • /NESTED=PRIMARY: search the default file type for headers using the context of the primary source files
  • /NESTED=NONE: do nothing

2. Search for the places specificed in the /INCLUDE directive. If it does not include the file types, look for .H files.

3. Is DECC$USER_INCLUDE defined?

If so: if /ASSUME=NOHEAD on the CC command, search DECC$USER_INCLUDE for any file types if /ASSUME=HEAD (or missing), search DECC$USER_INCLUDE for .H files If not, so nothing

4. If still not found, assume angle brackets and try the instructions below.

Angle bracketed includes

1. Search the / location

2. Search for the places specificed in the /INCLUDE directive. If it does not include the file types, look for .H files.

3. Is DECC$USER_INCLUDE defined? If so: if /ASSUME=NOHEAD on the CC command, search DECC$USER_INCLUDE for any file types if /ASSUME=HEAD (or missing), search DECC$USER_INCLUDE for .H files If not, so nothing.

4. Look at the definitions of DECC$LIBRARY_INCLUDE and DECC$SYSTEM_INCLUDE logicals.

  • both defined or only DECC$SYSTEM_INCLUDE is defined: search "DECC$SYSTEM_INCLUDE:.H", or just "DECC$SYSTEM_INCLUDE:." if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
  • only DECC$LIBRARY_INCLUDE is defined: search "DECC$LIBRARY_INCLUDE:.H", or just "DECC$LIBRARY_INCLUDE:." if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
  • neither is defined: search
SYS$COMMON:[DECC$LIB.INCLUDE.DECC$RTLDEF]*.H
SYS$COMMON:[DECC$LIB.INCLUDE.SYS$STARLET_C]*.H

5. Seacrch the libraries included with the /LIBRARY qualifier for modules with the same name. If /INCLUDE contained an empty string, stop there - otherwise also search DECC$TEXT_LIBRARY. If DECC$LIBRARY_INCLUDE is defined, do not search further. Otherwise search SYS$LIBRARY:DECC$RTLDEF.TLB and SYS$LIBRARY:SYS$STARLET_C.TLB for .H and . files and SYS$LIBRARY:SYS$STARLET_C.TLB for any files other than .H and .

6. Search SYS$LIBRARY:.H or . if /ASSUME=NOHEADER_TYPE_DEFAULT.