HP 3000 Manuals

HP C/iX Enhancements for MPE/iX 5.0 [ COMMUNICATOR 3000 MPE/iX General Release 5.0 (Core Software Release C.50.00) ] MPE/iX Communicators


COMMUNICATOR 3000 MPE/iX General Release 5.0 (Core Software Release C.50.00)

HP C/iX Enhancements for MPE/iX 5.0 

Colleen Bosholm 
Software Technology Division/Marketing and Support 

New Options 

The HP C/ANSI C compiler (Product # 31506A) has been enhanced for the
MPE/iX Release 5.0.  This article documents the changes in the C compiler
for this release.  Since the manual set will not be modified for the
MPE/iX 5.0 Release, this article fully documents all functionality
changes for the C Compiler.

The following list summarizes the functionality that has been added or
changed:

   *   +H command line option

   *   -Ae command line option

   *   +k command line option

   *   +f command line option

   *   -J command line option

   *   Sized enum

   *   libc functions

+H option.   

The +H option allows you to specify various call and exec privileges.
The new +H option has the following format:

     +H?       where ?  can be p, x, m or f 

       p = call privilege, p can be followed by 0, 1, 2 or 3.

       x = exec privilege, x can be followed by 0, 1, 2 or 3.

       m = memory resident, the subspace is to be locked in physical
       memory once the subspace goes into execution.

       f = initially frozen, the subspace is to be locked in physical
       memory when the operating system is being booted.

There can only be one +H option string.  All suboptions must, therefore,
be concatenated together.  The default privilege level for call priv (p)
and exec priv (x) is 3, which is the lowest privilege level, as opposed
to 0, which is the highest.

The following example shows the +H syntax:

     ccxl foo.c; INFO = "+Hp3x3mf"

-Ae option.   

This command line option requests a compilation in ANSI C mode with HP C
extensions.  This option is the same as specifying -Aa and +e.

The following example shows the -Ae syntax:

     ccxl foo.c; INFO = "-Ae"

+k option.   

This option is needed by programs that use a large number of global data
items.  Normally, a user program does not need this option.  If the
program does have too many global data items, the linker will display an
error message stating this.  The program should then be recompiled with
the +k option.

The following example shows the +k syntax:

     ccxl foo.c; INFO = "+k"

+f option.   

This command line option inhibits the promotion of float to double when
evaluating expressions.  This differs from the +r option in that both
parameters and function return values are still promoted to double.  In
ANSI mode, this option is ignored and a warning is issued.

The following example shows the +f syntax:

     ccxl foo.c; INFO = "+f"

-J option.   

This command line option improves run-time performance of standard C
routines by altering error condition checking.  With this option, the
compiler generates in-line assembly for strcpy (), sqrt (), and fabs () 
and converts printf () to putchar () under certain conditions.  This
option may alter the error handling of many routines declared in the
math.h header file.

The following example shows the -J syntax:

     ccxl foo.c; INFO = "-J"

Sized enum.   

Sized enumeration type is an HP C/iX extension.  By default, the HP C
compiler allocates four bytes for all enumerated variables.  However, if
you know that the range of values being assigned to an enum variable is
small, you can direct the compiler to allocate only one or two bytes by
using the char or short type specifier.  You can also use the long type
specifier to indicate 4-byte enums, even though this is the default.  For
example:

     enum default_enum {ERR1, ERR2, ERR3, ERR4};   /* 4-byte enum type */
     long enum big_enum {ST0, ST1, ST2, ST3};      /* 4-byte enum type */
     short enum small_enum  {cats, dogs};          /* 2-byte enum type */
     char enum tiny_enum {alpha, beta };           /* 1-byte enum type */

When mixed in expressions, enums behave exactly as their similarly sized
type counterparts do.  That is, an enum behaves like an int, a long enum
acts like a long int, and a short enum acts like a short int.  You will,
however, receive a warning message when you mix enum variables with
integer or floating-point types, with differently typed enums.  The
sizeof () function returns the actual storage allocated when called with
enum-specifier.


NOTE When called with enumeration-constant, the sizeof () function returns the value 4. Given the following declaration: char enum tiny_enum {alpha, beta}; /*1-byte enum type */ the call sizeof (char enum tiny_enum) returns 1, while the call sizeof (alpha) returns 4.
libc functions. There are three new library functions available in libc. They are vscanf (), vfscanf () and vsscanf (). vscanf () vscanf () reads formatted input data from the standard input stream stdin. #include <stdio.h> #include <stdarg.h> int vscanf (const char *format, va_list ap); This function is identical to the scanf () function except that it takes a va_list (as defined by stdarg.h) instead of a variable number of arguments. Please see the description for scanf () for more details. vfscanf () vfscanf () reads formatted input data from an open stream. int vfscanf (FILE *fp, const char *format, va_list ap); This function is identical to the fscanf () function except that it takes a va_list (as defined by stdarg.h) instead of a variable number of arguments. Please see the description for fscanf () for more details. vsscanf () vsscanf reads formatted data from a character string in memory. int vsscanf (char *s, const char *format, va_list ap); This function is identical to the sscanf () function except that it takes a va_list (as defined by stdarg.h) instead of a variable number of arguments. Please see the description for sscanf () for more details. New LIBC/iX Library To take advantage of the Shared Global feature in the 5.0 Push Release, there is a new C library, libcshr.lib.sys. This library allows you to link your program with other executable libraries (XL) in addition to xl.pub.sys. It can be used the same way as other libc libraries but requires the new share keyword. For example: link from=myobj;to=myprog;rl=libcansi.lib.sys,libcshr.lib.sys;share This links an ANSI conforming application myobj into a program file myprog with all libc functions as well as global variables resolved in xl.pub.sys.
NOTE The keyword share must be specified since the default linking mode is not shared.
Linking shared results in a much smaller application and allows you to take advantage of any new system release without relinking. Existing programs and scripts that use libc.lib.sys and libcinit.lib.sys continue to work without change. However, libcshr.lib.sys is the recommended library to use. The scripts ccxllk.pub.sys and ccxlgo.pub.sys are modified to link with libcshr.


MPE/iX Communicators