Skip to Main Content United States    
PRODUCTS SUPPORT SOLUTIONS SERVICES
COMPAQ SOFTWARE
Compaq C

Compaq C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index

New Functions

The Compaq C RTL includes the following new or modified functions for OpenVMS Version 7.3-1:


New feature-switch-setting functions:
 
   decc$feature_get_index 
   decc$feature_get_name 
   decc$feature_get_value 
   decc$feature_set_value 
 
New scanf functions:
 
   vfscanf       vfwscanf 
   vscanf        vwscanf 
   vsscanf       vswscanf 
 
New functions to support 64-bit file sizes & offsets:
 
   fseeko        ftello 
 
Functions modified to support 64-bit file sizes & offsets:
 
  fstat          mmap  
  ftruncate      stat 
  ftw            truncate 
  lseek           

New and Changed Features - Compaq C Version 6.4

The following C RTL enhancements were included in Compaq C Version 6.4 and OpenVMS Version 7.3:

  • The strptime function was made XPG5-compliant.
  • The limitation of eight nested directory levels was lifted (ALPHA ONLY).
  • Improved Support for Extended File Specifications (ALPHA ONLY).
    • Case preservation in file names is supported (ALPHA ONLY).
    • Most C RTL functions now accept long OpenVMS-style file names as arguments (ALPHA ONLY).
  • Support is added for exact-case argv arguments (ALPHA ONLY).
  • Files can be implicitly opened for shared access.
  • There is an alternative way of translating UNIX file specifications.
  • New C RTL functions are added.
  • Support is added for a new signal, SIGWINCH.
  • The socket routine socket_fd is changed to decc$socket_fd . This change is in the <socket.h> header file.
    Programs using this function need to be amended to call decc$socket_fd instead of socket_fd . Otherwise they will get implicit function declaration.

The strptime function was made XPG5-compliant

The strptime function has been modified to be compliant with X/Open CAE Specification System Interfaces and Headers Issue 5 (commonly known as XPG5). The change for XPG5 is in how the strptime function processes the "%y" directive for a two-digit year within the century if no century is specified.

When a century is not otherwise specified, XPG5 requires that values for the "%y" directive in the range 69-99 refer to years in the twentieth century (1969 to 1999 inclusive), while values in the range 00-68 refer to years in the twenty-first century (2000 to 2068 inclusive). Essentially, for the "%y" directive, strptime became a "pivoting" function, with 69 being a pivoting year.

Before this change, the strptime function interpreted a two-digit year with no century as a year within twentieth century.

With OpenVMS Version 7.3, XPG5-compliant strptime becomes a default strptime function in the Compaq C RTL. However, the previous non-pivoting XPG4-compliant strptime function is retained for compatibility.

The pivoting is controlled by the DECC$XPG4_STRPTIME logical name. To use the non-pivoting version of strptime , either:

  • Define DECC$XPG4_STRPTIME to any value before invoking the application.
    OR
  • Call the non-pivoting strptime directly as the function decc$strptime_xpg4 .

The limitation of eight nested directory levels was lifted (ALPHA ONLY)

The Compaq C RTL I/O subsystem was enhanced to remove the restriction of eight nested directory levels for an ODS-5 device. This affects Compaq C RTL functions such as access , mkdir , opendir , rmdir , and stat .

Improved Support for Extended File Specifications (ALPHA ONLY)

The following sections describe improved Compaq C RTL support for extended file specifications.

The Compaq C RTL supports case preservation in file names (ALPHA ONLY)

Programs linked against the Compaq C Run-time library DECC$SHR can now preserve the case of file names on ODS level 5 disks. This applies when creating or reporting file names. By default, this feature is disabled. To enable this feature enter the following command:


$ DEFINE DECC$EFS_CASE_PRESERVE ENABLE 

If file names are all in upper case, use the following command to convert the names into lower case when reporting the name in UNIX style:


$ DEFINE DECC$EFS_CASE_SPECIAL ENABLE 

If file names are not all in upper case, the preceding command preserves case.

The commands to disable the preceding logical-name settings are:


$ DEFINE DECC$EFS_CASE_PRESERVE DISABLE 
$ DEFINE DECC$EFS_CASE_SPECIAL DISABLE 

The setting for the DECC$EFS_CASE_SPECIAL logical name, if not set to DISABLE, supersedes any setting for the DECC$EFS_CASE_PRESERVE logical name.

The DECC$EFS_CASE_PRESERVE and DECC$EFS_CASE_SPECIAL logicals are checked only once per image activation, not on a file-by-file basis.

Most C RTL functions now accept long OpenVMS-style file names as arguments (ALPHA ONLY)

For OpenVMS Alpha Version 7.2, some basic Compaq C RTL I/O functions ( creat , stat , and the functions from the open family of functions) were enhanced to accept long OpenVMS-style file names for an ODS-5 device.

For OpenVMS Alpha Version 7.3, all other Compaq C RTL functions, except chdir and the functions from the exec family of functions, were also enhanced to accept long OpenVMS-style file names for an ODS-5 device.

All C RTL functions that accept or report full file specifications will process file specifications up to 4095 bytes long, subject to the rules defined for the media format. For file specifications in OpenVMS format, there are no special restrictions. In situations where a full file specification cannot be reported because the buffer is too short, the function attempts to report the abbreviated name.

UNIX file names have the following restrictions:

  • Names containing special characters, such as multiple periods, caret, or multinational characters, may be rejected.
  • A function call may report failure if the output buffer is not large enough to receive the full name. For OpenVMS style names, the reported name would contain a FID-abbreviated name. There is no representation of FID-abbreviated names defined for UNIX.

The Compaq C RTL supports exact-case argv arguments (ALPHA ONLY)

Nonquoted command-line arguments passed to C and C++ programs (argv arguments) can now optionally have their case preserved, rather than being lowercased as in previous versions.

By default, this feature is disabled.

To enable this case preservation feature, define the logical name DECC$ARGV_PARSE_STYLE to "ENABLE" and set the process-level DCL parse style flag to "EXTENDED" in the process running the program:


$ DEFINE DECC$ARGV_PARSE_STYLE ENABLE 
$ SET PROCESS/PARSE_STYLE=EXTENDED 

Enabling this feature also ensures that the image name returned in argv[0] is also case-preserved.

To disable this feature, use any one of the following commands:


 $ SET PROCESS/PARSE_STYLE=TRADITIONAL 

or


$ DEFINE/SYSTEM DECC$ARGV_PARSE_STYLE DISABLE 

or


$ DEASSIGN DECC$ARGV_PARSE_STYLE 

The value of the DECC$ARGV_PARSE_STYLE logical is case-insensitive.

The Compaq C RTL can implicitly open files for shared access

The Compaq C RTL was enhanced to open all files for shared access as if the "shr=del,get,put,upd" option was specified in the open* or creat call.

To enable this feature, define the logical name DECC$FILE_SHARING to "ENABLE". The value is case-insensitive.

DECC$FILE_SHARING is checked only once per image activation, not on a file-by-file basis.

Alternative way of translating UNIX file specs

The Compaq C RTL was enhanced to allow interpreting the leading part of a UNIX-style file spec as either a subdirectory name or a device name.

As with previous releases, the default translation of foo/bar (UNIX-style name) is FOO:BAR (OpenVMS-style device name).

To request translation of foo/bar (UNIX-style name) to [.FOO]BAR (OpenVMS-style subdirectory name), define the logical name DECC$DISABLE_TO_VMS_LOGNAME_TRANSLATION to any value. DECC$DISABLE_TO_VMS_LOGNAME_TRANSLATION is checked only once per image activation, not on a file-by-file basis.

New Functions

The Compaq C RTL has added the following functions in OpenVMS Version 7.3:


fchown            
link 
utime 
utimes 
writev 


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:

  • The linking process
  • The macro substitution process
  • The difference between function definitions and function calls
  • The format of valid file specifications
  • The OpenVMS-specific methods of input and output (I/O)
  • The Compaq C for OpenVMS extensions and nonstandard features

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:

  • You reduce the size of a program's executable image.
  • The program's image takes up less disk space.
  • The program swaps in and out of memory faster due to decreased size.
  • With Compaq C and Compaq C++, you no longer need to define an options file when linking your program against the shareable image. Linking against the RTL shareable image is now much simpler than it was with VAX C. In fact, it is the default method of linking to the Compaq C RTL.

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:

  • You must change any existing VAX C link procedures to eliminate any references to the VAXCRTL*.EXE images. An explicit reference to DECC$SHR.EXE is unnecessary because IMAGELIB.OLB is searched automatically by the linker (see the OpenVMS Linker Utility Manual).
  • 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 that you use.
    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:
    • Compile with the /PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES qualifier.
    • Compile with the /STANDARD=VAXC or /STANDARD=COMMON qualifier; you get /PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES as the default.

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:

  • VAXCCURSE.OLB
  • VAXCRTLD.OLB
  • VAXCRTLT.OLB
  • VAXCRTL.OLB
  • VAXCRTLX.OLB
  • VAXCRTLDX.OLB
  • VAXCRTLTX.OLB

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:

  • VAXCRTL.OLB contains all Compaq C RTL routine name entry points as well as VAX G-floating double-precision, floating-point entry points.
  • VAXCRTLD.OLB contains a limited support of VAX D-floating double-precision, floating-point entry points.
  • VAXCRTLT.OLB contains IEEE T-floating double-precision, floating-point entry points.
  • VAXCRTLX.OLB contains G_floating support and support for the /L_DOUBLE_SIZE=128 compiler qualifier.
  • VAXCRTLDX.OLB contains D_floating support and support for the /L_DOUBLE_SIZE=128 compiler qualifier.
  • VAXCRTLTX.OLB contains IEEE T_floating support and support for the /L_DOUBLE_SIZE=128 compiler qualifier.

/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



Previous Next Contents Index
Buy Online or Call 1.800.888.0220      privacy statement and legal notices 
STORES CONTACT US SEARCH PRODUCTS SOLUTIONS OPTIONS DEVELOPERS