Difference between revisions of "C Compiler"

From VSI OpenVMS Wiki
Jump to: navigation, search
(Created page with "The '''C Compiler''' is the software that compiles code written in C into object files. =Includes= CC /INCLUDE_DIRECTORY qualifier provides similar functionality to the -I o...")
 
Line 12: Line 12:
 
  /INCLUDE=""
 
  /INCLUDE=""
  
If you specify one of the places as an empty string, the compiler will not search for any of its conventionally-named places      (DECC$USER_INCLUDE, DECC$SYSTEM_INCLUDE, DECC$LIBRARY_INCLUDE, SYS$COMMON:[DECC$LIB.INCLUDE.*], DECC$TEXT_LIBRARY, DECC$RTLDEF.TLB, SYS$STARLET_C.TLB). It searches only places specified explicitly on the command line by the /INCLUDE_DIRECTORY and /LIBRARY qualifiers (or by the location of the primary source file, depending on the /NESTED_INCLUDE_DIRECTORY qualifier).
+
The interpretation depends on the format of the #include directive: whether it is is quotes or angle brackets:
  
The basic search order depends on the form of the header-file name (after macro expansion). Additional aspects of the search order are controlled by other command-line qualifiers and the presence or absence of logical name definitions.
 
 
==All forms of header-file inclusion==
 
 
* In quotes
 
 
  #include "stdio.h"
 
  #include "stdio.h"
 
* In angle brackets
 
 
  #include <stdio.h>
 
  #include <stdio.h>
 
* An identifier to be treated as a text-module name
 
        stdio
 
 
Except where otherwise specified, searching a "place" means that the string designating the place is used as the default file-spec in a call to an RMS [[System Service|system service]] (for example, [[$SEARCH]]/[[$PARSE]]), with a file-spec consisting of the name in the #include directive without enclosing delimiters. The search terminates successfully as soon as a file can be opened for reading.
 
  
 
==Quoted includes==
 
==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
  
1. One of the following:
+
2. Search for the places specificed in the /INCLUDE directive. If it does not include the file types, look for .H files.
 
 
* If /NESTED_INCLUDE_DIRECTORY=INCLUDE_FILE (the default) is in effect, search the directory containing the file in which the #include directive itself occurred. The meaning of "directory containing" is:  the RMS "resultant string" obtained when the file in which the #include occurred was opened, except that the filename and subsequent components are replaced by the default file type for headers (".H", or just "." if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect). The "resultant string" will not have translated any concealed device logical.
 
* If /NESTED_INCLUDE_DIRECTORY=PRIMARY_FILE is in effect, search the default file type for headers using the context of the primary source file.  This means that just the file type (".H" or ".") is used for the default file-spec but, in addition, the chain of "related file-specs" used to maintain the sticky defaults for processing the next top-level source file is applied when searching for the include file.
 
* If /NESTED_INCLUDE_DIRECTORY=NONE is in effect, this entire step (Step 1) is bypassed.
 
  
2. Search the places specified in the /INCLUDE_DIRECTORY qualifier, if any.  A place that can be parsed successfuly as an OpenVMS file-spec and that does not contain an explicit file type or version specification is edited to append the default header file type specification (".H" or ".").
+
3. Is DECC$USER_INCLUDE defined?
  
A place containing a "/" character is considered to be a UNIX-style name.  If the name in the #include directive also contains a "/" character that is not the first character and is not preceded by a "!" character (that is, it is not an absolute UNIX-style pathname), then the name in the #include directive is appended to the named place, separated by a "/" character, before applying the decc$to_vms pathname translation function.
+
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
  
3.  If "DECC$USER_INCLUDE" is defined as a logical name, search "DECC$USER_INCLUDE:.H", or just "DECC$USER_INCLUDE:." if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
+
4. If still not found, assume angle brackets and try the instructions below.
 
 
4. If the file is not found, follow the steps for the angle-bracketed form of inclusion.
 
  
 
==Angle bracketed includes==
 
==Angle bracketed includes==
  
1. Search the place "/".  This is a UNIX-style name that can combine only with UNIX names specified explicitly in the #include directive.  It causes a specification like <sys/types.h> to be considered first as /sys/types.h, which is translated to SYS:TYPES.H.
+
1. Search the / location
 
 
2.  Search the places specified in the /INCLUDE_DIRECTORY qualifier, exactly as in Step 2 for the quoted form of inclusion.
 
 
 
3.  If "DECC$SYSTEM_INCLUDE" is defined as a logical name, search "DECC$SYSTEM_INCLUDE:.H", or just "DECC$SYSTEM_INCLUDE:." if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
 
 
 
4.  If "DECC$LIBRARY_INCLUDE" is defined as a logical name and "DECC$SYSTEM_INCLUDE" is NOT defined as a logical name, search "DECC$LIBRARY_INCLUDE:.H", or just "DECC$LIBRARY_INCLUDE:." if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
 
 
 
5.  If neither "DECC$LIBRARY_INCLUDE" nor "DECC$SYSTEM_INCLUDE" are defined as logical names, then search the default list of places for plain text-file copies of compiler header files as follows:
 
 
 
        SYS$COMMON:[DECC$LIB.INCLUDE.DECC$RTLDEF]*.H
 
        SYS$COMMON:[DECC$LIB.INCLUDE.SYS$STARLET_C]*.H
 
 
 
If the file is not found, perform the text library search described in the next step.
 
 
 
6.  Extract the simple filename and file type from the #include specification and use the filename as the module name to search a list of text libraries associated with that file type. For any file type, the initial text libraries searched consist of those named on the command line with /LIBRARY qualifiers. If the /INCLUDE_DIRECTORY qualifier contained an empty string,no further text libraries are searched.  Otherwise, DECC$TEXT_LIBRARY is searched for all file types. If "DECC$LIBRARY_INCLUDE" is defined as a logical name, then no further text libraries are searched.  Otherwise, the subsequent libraries searched for each file type are:
 
 
 
- For ".H" or ".":
 
 
 
                SYS$LIBRARY:DECC$RTLDEF.TLB
 
                SYS$LIBRARY:SYS$STARLET_C.TLB
 
 
 
- For any file type other then ".H" or ".":
 
 
 
                SYS$LIBRARY:SYS$STARLET_C.TLB
 
 
 
7.  If the previous step fails, search:
 
 
 
        SYS$LIBRARY:.H
 
  
Under /ASSUME=NOHEADER_TYPE_DEFAULT, the default file type is modified as usual.
+
2. Search for the places specificed in the /INCLUDE directive. If it does not include the file types, look for .H files.
For the text-module (non-portable) form of #include:
 
  
The name can only be an identifier. It, therefore, has no  associated "file type". The identifier is used as a module name to search the following:
+
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.
  
1. The text libraries named on the command line with /LIBRARY qualifiers, in left-to-right order.
+
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
  
2. The following list of text libraries in the order shown (unless the /INCLUDE_DIRECTORY qualifier contains an empty string, in which case no further text libraries are searched):
+
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 .
  
            DECC$TEXT_LIBRARY
+
6. Search SYS$LIBRARY:.H or . if /ASSUME=NOHEADER_TYPE_DEFAULT.
            SYS$LIBRARY:DECC$RTLDEF.TLB
 
            SYS$LIBRARY:SYS$STARLET_C.TLB
 

Revision as of 11:52, 19 September 2023

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

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.