United States    
COMPAQ STORE | PRODUCTS |
SERVICES | SUPPORT | CONTACT US | SEARCH
Compaq C

Compaq C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


Chapter 1
Introduction

The ISO/ANSI C standard defines a library of functions, as well as related types and macros, to be provided with any implementation of ANSI C. The Compaq C Language Reference Manual describes the ANSI-conformant library features common to all Compaq C platforms. The Compaq C Run-Time Library Reference Manual for OpenVMS Systems provides a more detailed description of these routines and their use in the OpenVMS environment. It also documents additional header files, functions, types, and macros that are available on the OpenVMS system.

All library functions are declared in a header file. To make the contents of a header file available to your program, include the header file with an #include preprocessor directive. For example:


#include <stdlib.h> 

Each header file contains function prototypes for a set of related functions, and defines any types and macros needed for their use.

To list the header files on OpenVMS Alpha systems, use the following commands:


$ LIBRARY/LIST ALPHA$LIBRARY:SYS$STARLET_C.TLB
  (ALPHA ONLY)
 
$ LIBRARY/LIST ALPHA$LIBRARY:DECC$RTLDEF.TLB
  (ALPHA ONLY)
 
$ DIR SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF]*.H;
  (ALPHA ONLY)
 
$ DIR ALPHA$LIBRARY:*.H; 
  (ALPHA ONLY)

The first command lists the text module form of the header files for the OpenVMS system interfaces. The second lists the text module form of the header files for the Compaq C language interface. The third lists *.h header files for the Compaq C language interfaces. The fourth lists *.h header files for layered products and other applications.

Note

The SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF] directory is only a reference area for your viewing. The compiler still looks in the *.TLB files for #include file searches.

To list the header files on OpenVMS VAX systems, use one of the following command:


$ DIR 'F$TRNLMN("DECC$LIBRARY_INCLUDE")'*.H;  (VAX ONLY)
$ DIR DECC$LIBRARY_INCLUDE:*.H;  (VAX ONLY)

On OpenVMS VAX systems, the following command might also find additional or duplicate header files:


$ DIR SYS$LIBRARY:*.H;  (VAX ONLY)

However, duplicate files (such as <stdio.h> ) found in SYS$LIBRARY probably support the VAX C Version 3.2 environment and should not be used with Compaq C.

Function definitions themselves are not included in the header files, but are contained in the Compaq C Run-Time Library (RTL) shipped with the OpenVMS operating system. Before using the Compaq C RTL, you must be familiar with the following topics:

A knowledge of all these topics is necessary to effectively use the Compaq C RTL. This chapter shows the connections between these topics and the Compaq C RTL. Read this chapter before any of the other chapters in this manual.

The primary purpose of the Compaq C RTL is to provide a means for C programs to perform I/O operations; the C language itself has no facilities for reading and writing information. In addition to I/O support, the Compaq C RTL also provides a means to perform many other tasks.

Chapters 2 through 11 describe the various tasks supported by the Compaq C RTL. The Reference Section alphabetically lists and describes all the functions and macros available to perform these tasks.

1.1 Using the Compaq C Run-Time Library

When working with the Compaq C RTL, you must be aware of some implementation specifics.

First, if you plan to use Compaq C RTL functions in your C programs, make sure that a function named main or a function that uses the main_program option exists in your program. For more information, see the Compaq C Language Reference Manual or the Compaq C User's Guide for OpenVMS Systems.

Second, the Compaq C RTL functions are executed at run time, but references to these functions are resolved at link time. When you link your program, the OpenVMS Linker resolves all references to Compaq C RTL functions by searching any shareable code libraries or object code libraries specified on the LINK command line.

You can use the Compaq C RTL as a shareable image or you can use the Compaq C RTL object libraries.

When you use the Compaq C RTL as a shareable image, the code for the RTL resides in an image file in SYS$SHARE and is shared by all Compaq C programs. After execution, control returns to your program. This process has a number of advantages:

When linking to the Compaq C RTL, you do not need to define any LNK$LIBRARY logicals. In fact, you should deassign LNK$LIBRARY because linking with the shareable image is more convenient than linking with the Compaq C RTL object libraries.

See your OpenVMS, Compaq C, or Compaq C++ release notes for any supplemental information about linking with the Compaq C RTL.

1.2 RTL Linking Options on Alpha Systems (ALPHA ONLY)

The following sections describe several ways of linking Compaq C and Compaq C++ programs with the Compaq C RTL on OpenVMS Alpha systems.

1.2.1 Linking with the Shareable Image

Most linking needs should be satisfied by using the Compaq C RTL shareable image DECC$SHR.EXE in the ALPHA$LIBRARY directory.

The shareable images VAXCRTL.EXE and VAXCRTLG.EXE do not exist on OpenVMS Alpha systems. The only C RTL shareable image is ALPHA$LIBRARY:DECC$SHR.EXE, which the linker automatically finds through IMAGELIB.OLB.

The fact that VAXCRTL*.EXE does not exist on Alpha systems has the following ramifications:

To link against the shareable image, use the LINK command. For example:


$ LINK PROG1

The linker automatically searches IMAGELIB.OLB to find DECC$SHR.EXE, and resolves all C RTL references.

Note

In OpenVMS Alpha Version 7.0, the Compaq C Run-Time Library functions whose names are of the form decc$fmath_2, are defined in STARLET, but are not universal symbols in the DECC$SHR image. When these functions are referenced by an application, linking the image results in inclusion of the DECC$SHR image from IMAGELIB and the specific C math modules from STARLET. If neither the DPML$SHR image or the CMA$TIS_SHR image were already brought in during the IMAGELIB phase, the object form is included from STARLET because references to these symbols appear in the STARLET phase. In OpenVMS Version 7.0, this resulted in the undefined symbols:
CMA$TIS_ERRNO_SET_VALUE
CMA$TIS_VMS_ERRNO_SET_VALUE


In OpenVMS Alpha Version 7.1, the decc$fmath_2 symbols have been added to the DECC$SHR image so that both the DPML$SHR and CMA$TIS_SHR references are now resolved using shareable images found in IMAGELIB.

1.2.2 Linking with the Object Libraries

The Compaq C RTL object libraries are used solely for linking programs compiled without /PREFIX=ALL.

On OpenVMS Alpha systems, the Compaq C RTL provides the following object libraries in the ALPHA$LIBRARY directory:

The object library VAXCCURSE.OLB, which provides access to the curses functions, contains unprefixed entry points that vector to the appropriate prefixed entry points.

The object libraries VAXCRTL.OLB, VAXCRTLD.OLB, VAXCRTLT.OLB, VAXCRTLX.OLB, VAXCRTLDX.OLB, and VAXCRTLTX.OLB also contain unprefixed entry points that vector to the appropriate prefixed entry points, depending on the floating-point type specified by the object library used:

/L_DOUBLE_SIZE=128 is the default.

On the LINK command, specify only one of the VAXCRTL*.OLB libraries and, if needed, the VAXCCURSE.OLB library.

In the default mode of the compiler (/STANDARD=RELAXED_ANSI89) and also in strict ANSI C mode, all calls to ANSI C standard library routines are automatically prefixed with DECC$. With the /[NO]PREFIX_LIBRARY_ENTRIES qualifier, you can change this to prefix all Compaq C RTL names with DECC$, or to not prefix any Compaq C RTL names. Other options are also available for this qualifer. See the /[NO]PREFIX_LIBRARY_ENTRIES qualifier in this chapter for more information.

When linking with /NOSYSSHR, if calls to the Compaq C RTL routines are prefixed with DECC$, then the modules in STARLET.OLB are the only ones you need to link against. Since STARLET.OLB is automatically searched by the linker (unless the link qualifier /NOSYSLIB is used), all prefixed RTL external names are automatically resolved.

If any calls to the Compaq C RTL routines are not prefixed, then you need to explicitly link against VAXCRTL.OLB, VAXCRTLD.OLB, VAXCRTLT.OLB (or VAXCRTLX.OLB, VAXCRTLDX.OLB, or VAXCRTLDX.OLB), or VAXCCURSE.OLB, depending on which floating-point types you need, or if you want curses functions. If you are linking with /NOSYSSHR, prefixed Compaq C RTL entry points are resolved in STARLET.OLB. If you are linking with /SYSSHR (the default), prefixed Compaq C RTL entry points are resolved in DECC$SHR.EXE.

1.2.3 Examples

The following examples show several different ways you might want to link with the Compaq C RTL. See Figure 1-1 for a graphical summary of these examples.

  1. Most of the time, you just want to link against the shareable image:


    $ CC/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES PROG1
    $ LINK PROG1
    

    The linker automatically searches IMAGELIB.OLB to find DECC$SHR.EXE.

  2. If you want to use just object libraries (to write privileged code or for ease of distribution, for example), use the /NOSYSSHR qualifier of the LINK command:


    $ CC/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES PROG1
    $ LINK/NOSYSSHR PROG1
    

    Prefixed RTL symbol references in the user program are resolved in the Compaq C RTL object library contained in STARLET.OLB.

    Notes

    • When linking Compaq C programs against the Compaq C RTL object libraries using the /NOSYSSHR qualifier, applications that previously linked without undefined globals may result in undefined globals for the CMA$TIS symbols. To resolve these undefined globals, add the following line to your link options file:


      SYS$LIBRARY:STARLET.OLB/LIBRARY/INCLUDE=CMA$TIS 
      

    • If a program linked with the /NOSYSSHR qualifier makes a call to a routine that resides in a dynamically activated image, and the routine returns a value indicating an unsuccessful status, errno is set to ENOSYS, and vaxc$errno is set to C$_NOSYSSHR. The error message corresponding to C$_NOSYSSHR is "Linking /NOSYSSHR disables dynamic image activation." An example of this situation is a program linked with /NOSYSSHR that makes a call to a socket routine.
  3. When compiling with prefixing disabled, in order to use object libraries that provide alternate implementations of C RTL functions, you need to use the VAXC*.OLB object libraries. In this case, compile and link as follows:


    $ CC/NOPREFIX_LIBRARY_ENTRIES PROG1
    $ LINK PROG1, MYLIB/LIBRARY, ALPHA$LIBRARY:VAXCRTLX.OLB/LIBRARY
    

    Unprefixed Compaq C RTL symbol references in the user program are resolved in MYLIB and in VAXCRTL.OLB.
    Prefixed Compaq C RTL symbol references in VAXCRTLX.OLB are resolved in DECC$SHR.EXE through IMAGELIB.OLB.
    In this same example, to get IEEE T-floating double-precision floating-point support, you might use the following compile and link commands:


    $ CC/NOPREFIX_LIBRARY_ENTRIES/FLOAT=IEEE_FLOAT PROG1
    $ LINK PROG1, MYLIB/LIBRARY, ALPHA$LIBRARY:VAXCRTLTX.OLB/LIBRARY 
    

  4. Combining examples 2 and 3, you might want to use just the object libraries (for writing privileged code or for ease of distribution) and use an object library that provides C RTL functions. In this case, compile and link as follows:


    $ CC/NOPREFIX_LIBRARY_ENTRIES PROG1
    $ LINK/NOSYSSHR PROG1, MYLIB/LIBRARY, ALPHA$LIBRARY:VAXCRTLX.OLB/LIBRARY
    

    Prefixed Compaq C RTL symbol references in VAXCRTL.OLB are resolved in STARLET.OLB.

Figure 1-1 Linking with the Compaq C RTL on OpenVMS Alpha Systems


1.3 RTL Linking Options on VAX Systems (VAX ONLY)

Both the VAX C RTL and the Compaq C RTL can coexist on your OpenVMS VAX system. The VAX C RTL supports existing VAX C applications. The Compaq C RTL supports ANSI-compliant Compaq C and Compaq C++, as well as other components of the OpenVMS environment. The Compaq C RTL also provides a mechanism for thread safety and performance improvements.

Applications developed with VAX C will continue to use the VAX C RTL. However, you can relink VAX C applications to use the Compaq C RTL instead. This lets you take advantage of the new features of the Compaq C RTL and solve potential interoperability problems in complex applications that incorporate both the VAX C RTL and the Compaq C RTL. Existing applications that are relinked to use the Compaq C RTL should be carefully tested for possible problems resulting from the differences in behavior between the VAX C RTL and the Compaq C RTL. See the applicable Compaq C release notes and OpenVMS release notes for more information.

The following sections describe several ways of linking Compaq C programs with the Compaq C RTL and VAX C RTL on OpenVMS VAX systems.

1.3.1 Linking with the Compaq C RTL

The Compaq C RTL provides a new set of files with different names from the VAX C RTL files. If you want to link with the Compaq C RTL, you need to change your link procedures to use the new file names. The following sections describe linking with the Compaq C RTL files.

1.3.1.1 Linking with the Compaq C RTL Shareable Images

Most linking needs should be satisfied by using the Compaq C RTL shareable image DECC$SHR.EXE in the SYS$LIBRARY directory. Use this linking method for programs that are written entirely in Compaq C or Compaq C++ code; that is, with no VAX C object modules.

Because DECC$SHR.EXE exports only prefixed universal symbols (ones that begin with DECC$), to successfully link against it make sure you cause prefixing to occur for all Compaq C RTL entry points.

If you use only the Compaq C RTL functions defined in the ANSI C Standard, all entry points will be prefixed.

If you use Compaq C RTL functions not defined in the ANSI C Standard, you must compile in one of two ways to ensure prefixing:

Then link against the shareable image using the LINK command. For example:


$ LINK PROG1

If you are using the VAX C compiler and you want to link with DECC$SHR.EXE, you must link to one of the following files:

VAXC2DECC.EXE
VAXCG2DECC.EXE

You link with them as follows:


$ LINK PROG1,TT:/OPTIONS
SYS$LIBRARY:VAXC2DECC/SHARE
[Ctrl/Z]

Use the G-floating version, VAXCG2DECC.EXE, if you compiled with the /G_FLOAT or /FLOAT=G_FLOAT qualifier.

1.3.1.2 Linking with or Providing Your Own Shareable Images

Most linking needs for an application using a shareable image are handled by a straight forward link command, regardless of whether the shared image uses Compaq C, VAX C or some other programming language.

For example, assume that SHARE1.EXE is a shareable image linked with VAXCRTL.EXE. Also assume that your program, PROG1, is compiled with Compaq C and, therefore, references prefixed names for C RTL functions. You can then use the following commands:


$ LINK PROG1, SYS$INPUT:/OPTIONS 
MYDISK:[TEXT]SHARE1.EXE/SHARE 

If PROG1 does not use prefixed names, the link could result in link conflicts. If this occurs, see Section 1.3.2.

1.3.1.3 Linking with the Compaq C RTL Object Libraries

The Compaq C RTL object libraries are used primarily for linking with the /NOSYSSHR qualifier.

On OpenVMS VAX systems, the Compaq C RTL provides the following object libraries in the SYS$LIBRARY directory:

As with VAX C, if you specify more than one object library on the LINK command, you must do so in the order listed.

You use these object libraries in the same way that you would use the VAX C RTL object libraries VAXCRTL.OLB, VAXCRTLG.OLB, and VAXCCURSE.OLB. For example:


$ ! Link a D-float program
$ LINK PROG1, SYS$LIBRARY:DECCRTL.OLB/LIBRARY
$ !
$ ! Link a G-float program
$ LINK PROG2, SYS$LIBRARY:DECCRTLG.OLB/LIBRARY, - 
_$ SYS$LIBRARY:DECCRTL.OLB/LIBRARY
$ !
$ ! Link a D-float, curses program
$ LINK PROG1, SYS$LIBRARY:DECCCURSE.OLB/LIBRARY, - 
_$ SYS$LIBRARY:DECCRTL.OLB/LIBRARY

Note

When linking to the Compaq C RTL object libraries, you do not need to define any LNK$LIBRARY logicals. In fact, you must deassign LNK$LIBRARY when linking with the .OLB libraries; otherwise, you might see "multiply defined symbols" errors.

In general, you should deassign LNK$LIBRARY because pointing this logical to the Compaq C RTL object libraries interferes with VAX C development.

1.3.1.4 Linking with the Compaq C RTL Object Libraries /NOSYSSHR

If you want to link your program with the Compaq C RTL object libraries using the /NOSYSSHR qualifier, you must specify /INCLUDE=CMA$TIS for the object library. For OpenVMS VAX Version 7.3 and higher, you must specify /INCLUDE=(CMA$TIS,CMA$TIS_VEC). Otherwise, several symbols will be undefined and the resulting image will not execute.

In order to add this qualifier, you cannot use the LNK$LIBRARY logicals to link with the Compaq C RTL. You must use a linker options file or list the Compaq C RTL object library on the command line. For example:


$ LINK/NOSYSSHR PROG1, SYS$LIBRARY:DECCRTL.OLB/LIBRARY/INCLUDE=CMA$TIS
 
 
$ LINK/NOSYSSHR PROG1, -
_$ SYS$LIBRARY:DECCRTL.OLB/LIBRARY/INCLUDE=(CMA$TIS,CMA$TIS_VEC) (OPENVMS V7.3 AND HIGHER) 
 

Notes

  • When linking Compaq C programs against the Compaq C RTL object libraries using the /NOSYSSHR qualifier, applications that previously linked without undefined globals may result in undefined globals for the CMA$TIS symbols. To resolve these undefined globals, add the following line to your link options file:


    SYS$LIBRARY:STARLET.OLB/LIBRARY/INCLUDE=CMA$TIS 
     
    SYS$LIBRARY:STARLET.OLB/LIBRARY/INCLUDE=(CMA$TIS,CMA$TIS_VEC) (OPENVMS V7.3 AND HIGHER)
     
    

  • If a program linked with the /NOSYSSHR qualifier makes a call to a routine that resides in a dynamically activated image, and the routine returns a value indicating an unsuccessful status, errno is set to ENOSYS, and vaxc$errno is set to C$_NOSYSSHR. The error message corresponding to C$_NOSYSSHR is "Linking /NOSYSSHR disables dynamic image activation." An example of this situation is a program linked with /NOSYSSHR that makes a call to a socket routine.


Previous Next Contents Index
  

1.800.AT.COMPAQ

privacy and legal statement