1.4 DEC C RTL Function Prototypes and Syntax

After learning how to link object modules and include header files, you must learn how to reference DEC C functions in your program. The remaining chapters in this manual provide detailed descriptions of the DEC C RTL functions.

1.4.1 Function Prototypes

In all chapters, the syntax describing each function follows the standard convention for defining a function. This syntax is called a function prototype (or just prototype). The prototype is a compact representation of the order of a function's arguments (if any), the types of the arguments, and the type of the value returned by a function. The use of prototypes is recommended.

If the return value of the function cannot be easily represented by a C data-type keyword, look for a description of the return values in the explanatory text. The prototype descriptions provide insight into the functionality of the function. These descriptions may not describe how to call the function in your source code.

For example, consider the prototype for the feof function:

#include <stdio.h>
int feof(FILE *file_ptr;)

This syntax shows the following information:

To use feof in a program, include <stdio.h> anywhere before the function call to feof, as in the following example:

#include <stdio.h>                 /* Include Standard I/O     */

main()
{

    FILE *infile;                  /* Define a file pointer    */
       .
       .
       .                           /* Call the function feof   */
    while ( ! feof(infile) )       /* Until EOF reached        */
       {                           /* Perform file operations  */
          .
          .
          .
       }
}

1.4.2 Syntax Conventions for Function Prototypes

Since some library functions take a varying number of parameters, syntax descriptions for function prototypes adhere to the following conventions:

Consider the printf syntax description:

#include <stdio.h>
int printf(const char *format_specification, . . . )

The syntax description for printf shows that you can specify one or more optional parameters. The remaining information about printf parameters is in the description of the function.

1.4.3 UNIX Style File Specifications

The DEC C RTL functions and macros often manipulate files. One of the major portability problems is the different file specifications used on various systems. Since many C applications are ported to and from UNIX systems, it is convenient for all compilers to be able to read and understand UNIX system file specifications.

The following file specification conversion functions are included in the DEC C RTL to assist in porting C programs from UNIX systems to OpenVMS systems:


Note
These DECC$ routine names replace the SHELL$ routine names previously available with the VAX C RTL.

For more information about the DEC/Shell, see the Guide to VAX DEC/Shell.

The advantage of including these file specification conversion functions in the DEC C RTL is that you do not have to rewrite C programs containing UNIX system file specifications. DEC C can translate most valid UNIX system file specifications to OpenVMS file specifications.


Note
The DEC C RTL cannot translate UNIX file specifications with more than one period character (.). If the UNIX file specification contains a period, all slash characters (/) must precede that period.

Please note the differences between the UNIX system and OpenVMS file specifications, as well as the method used by the RTL to access files. For example, the RTL accepts a valid OpenVMS specification and most valid UNIX file specifications, but the RTL cannot accept a combination of both. Table 1-2 shows the differences between UNIX system and OpenVMS system file specification delimiters.

Table 1-2 UNIX and OpenVMS File Specification Delimiters

Description  OpenVMS System  UNIX System 
Node delimiter  ::  !/ 
Device delimiter 
Directory path delimiter  [ ] 
Subdirectory delimiter  [ . ] 
File extension delimiter 
File version delimiter  Not applicable 

For example, Table 1-3 shows the formats of two valid specifications and one invalid specification.

Table 1-3 Valid and Invalid UNIX and OpenVMS File Specifications

System  File Specification  Valid/Invalid 
OpenVMS  BEATLE::DBA0:[MCCARTNEY]SONGS.LIS  Valid 
UNIX  beatle! /usr1/mccartney/songs.lis  Valid 
     
-   BEATLE::DBA0:[MCCARTNEY.C]/songs.lis  Invalid 

When DEC C translates file specifications, it looks for both OpenVMS and UNIX system file specifications. Consequently, there may be differences between how DEC C translates UNIX system file specifications and how UNIX systems translate the same UNIX file specification.

For example, if the two methods of file specification are combined, as in Table 1-3, DEC C RTL can interpret [MCCARTNEY.C]/songs.lis as either [MCCARTNEY]songs.lis or [C]songs.lis. Therefore, when DEC C encounters a mixed file specification, an error occurs.

UNIX systems use the same delimiter for the device name, the directory names, and the file name. Due to the ambiguity of UNIX file specifications, DEC C may not translate a valid UNIX system file specification according to your expectations.

For instance, the OpenVMS system equivalent of /bin/today can be either [BIN]TODAY or [BIN.TODAY]. DEC C can make the correct interpretation only from the files present. If a file specification conforms to UNIX system file name syntax for a single file or directory, it is converted to the equivalent OpenVMS file name if one of the following conditions is true:

In the UNIX system environment, you reference files with a numeric file descriptor. Some file descriptors reference Standard I/O devices; some descriptors reference actual files. If the file descriptor belongs to an unopened file, the DEC C RTL opens the file. DEC C equates file descriptors with the following OpenVMS logical names:
File Descriptor  OpenVMS Logical  Meaning 
SYS$INPUT  Standard input 
SYS$OUTPUT  Standard output 
SYS$ERROR  Standard error 


Previous Page | Next Page | Table of Contents | Index