HP C/iX Enhancements for MPE/iX 5.0 [ COMMUNICATOR 3000 MPE/iX Release 5.0 (Core Software Release X.50.20) ] MPE/iX Communicators
COMMUNICATOR 3000 MPE/iX Release 5.0 (Core Software Release X.50.20)
HP C/iX Enhancements for MPE/iX 5.0
Colleen Bosholm
STD/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
* +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 enables ANSI C compliance when _HPUX_SOURCE name
space macro is enabled. In other words, this requests a compilation in
ANSI C mode with HP C extensions. This option is the same as specifying
-Aa, -D _HPUX_SOURCE, and +e.
The following example shows the -Ae syntax:
ccxl foo.c; INFO = "-Ae"
+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
(), vfscan () 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.
vfscan ().
vfscan () reads formatted input data from an open stream.
int vfscan () (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.
MPE/iX Communicators