10. VMS

In this section, we will report some common problems encountered when porting a C program to a VMS environment and which we have not mentioned previously.

10.1. File Specifications

Under VMS, one can use two flavors of command interpreters: DCL and DEC/Shell. The syntax of file specifications under DCL differs significantly from the Unix syntax.

Some C run-time library functions in VMS that take file specifications as arguments or return file specifications to the caller, will accept an additional argument indicating which syntax is preferred. It is useful to use these run-time library functions via macros as follows:

#ifdef  VMS
#  ifndef VMS_CI        /* Which Command Interpreter to use */
#    define VMS_CI  0   /* 0 for DEC/Shell, 1 for DCL */
#  endif

#  define  Getcwd(buff,siz)   getcwd((buff),(siz),VMS_CI)
#  define  Getname(fd,buff)   getname((fd),(buff),VMS_CI)
#  define  Fgetname(fp,buff)  fgetname((fp),(buff),VMS_CI)

#else  /* !VMS */
#  define  Getcwd(buff,siz)   getcwd((buff),(siz))
#  define  Getname(fd,buff)   getname((fd),(buff))
#  define  Fgetname(fp,buff)  fgetname((fp),(buff))

#endif /* !VMS */

More pitfalls await the unaware who accept file specifications from the user or take them from environment values (e.g., using the getenv function).

10.2. Miscellaneous

end, etext, edata:
these global symbols are not available under VMS.

struct assignments:
VAX C allows assignment of different types of structs if both types have the same size. This is not a portable feature.

The system function:
the system function under VMS has the same functionality as the Unix version, except that one must take care that the command interpreter also provides the same functionality. If the user is using DCL, then the application must send a DCL-like command.

The linker:
what follows applies only to modules stored in libraries. (16) If none of the global functions are explicitly used (referenced by another module), then the module is not linked at all. It does not matter whether one of the global variables is used. As a side effect, the initialization of variables is not done.

The easiest solution is to force the linker to add the module using the /INCLUDE command modifier. Of course, there is the possibility that the command line may exceed 256 characters...(*sigh*).


16. This does not really belong in this document, but whenever one is porting a program to a VMS environment one is bound to come across this strange behavior which can result in a lot of wasted time.


upcontents previousUsing Floating-Point Numbers nextGeneral Guidelines