Jump to 
content
HP.com Home Products and Services Support and Drivers Solutions How to Buy
»  Contact HP

 

HP C

HP C
User's Guide for OpenVMS Systems


Previous Contents Index

5.4.22 #pragma unroll Directive

Use the #pragma unroll preprocessor directive to unroll the for loop that follows it by the number of times specified in unroll_factor. The #pragma unroll directive must be followed by a for statement.

This pragma has the following format:

#pragma unroll (unroll_factor)

The unroll_factor is an integer constant in the range of 0 to 255. If a value of 0 is specified, the compiler ignores the directive and determines the number of times to unroll the loop in its normal way. A value of 1 prevents the loop from being unrolled. The directive applies only to the for loop that follows it, not to any subsequent for loops.

5.4.23 #pragma use_linkage Directive

After defining a special linkage using the #pragma linkage directive, described in Section 5.4.11, use the #pragma use_linkage directive to associate the linkage with a function.

This pragma has the following format:

#pragma use_linkage linkage-name (id1, id2, ...)

The linkage-name is the name of a linkage previously defined by the #pragma linkage directive.

id1, id2, ... are the names of functions, or typedef names of function type, that you want associated with the specified linkage.

If you specify a typedef name of function type, then functions or pointers to functions declared using that type will have the specified linkage.

The #pragma use_linkage directive must appear in the source file before any use or definition of the specified routines. Otherwise, the results are unpredictable.


Examples

#1

#pragma linkage example_linkage = (parameters(r16, r17, r19), result(r16)) 
#pragma use_linkage example_linkage (sub) 
int sub (int p1, int p2, short p3); 
 
main() 
{ 
    int result; 
 
    result = sub (1, 2, 3); 
} 
 
      

This example defines a special linkage and associates it with a routine that takes three integer parameters and returns a single integer result in the same location where the first parameter was passed.

The result (r16) option indicates that the function result will be returned in R16 rather than the usual location (R0). The parameters option indicates that the three parameters passed to sub should be passed in R16, R17, and R19.

#2

#pragma linkage foo = (parameters(r1), result(r4)) 
#pragma use_linkage foo(f1,t) 
 
int f1(int a); 
typedef int t(int a); 
 
t *f2; 
 
#include <stdio.h> 
 
main() { 
    f2 = f1; 
    b = (*f2)(1); 
} 
 
      

In this example, both the function f1 and the function type t are given the linkage foo . The invocation through the function pointer f2 will correctly invoke the function f1 using the special linkage.


Chapter 6
Predefined Macros and Built-In Functions

This chapter describes the following topics:

Predefined macros and built-in functions are extensions to the C Standard and are specific to HP C for OpenVMS Systems. The macros assist in transporting code and performing simple tasks that are common to many programs. The built-in functions allow you to efficiently access processor instructions.

6.1 Predefined Macros

In addition to the standard-conforming, implementation-independent macros described in the HP C Language Reference Manual, HP C for OpenVMS Systems provides the predefined macros described in the following sections.

6.1.1 CC$gfloat (G_Floating Identification Macro)

This macro is provided for compatibility with VAX C. The __G_FLOAT predefined macro should be used instead. See Section 6.1.4.

6.1.2 System Identification Macros

Each implementation of the HP C compiler automatically defines macros that can be used to identify the system on which the program is running. These macros can assist in writing code that executes conditionally, depending on the architecture or operating system on which the program is running.

Table 6-1 lists the traditional (nonstandard) and new (standard) spellings of these predefined macro names for HP C for OpenVMS Systems. Both spellings are defined for each macro unless strict ANSI C mode (/STANDARD=ANSI89) is in effect, in which case only the new spellings are defined.

Table 6-1 Predefined System Identification Macros
  Traditional Spelling New Spelling
Operating system name: vms __vms
  VMS __VMS
  vms_version __vms_version
  VMS_VERSION __VMS_VERSION
    __VMS_VER
    __DECC_VER
Architecture name: vax (VAX ONLY) __vax (VAX ONLY)
  VAX (VAX ONLY) __VAX (VAX ONLY)
    __alpha (ALPHA ONLY)
    __ALPHA (ALPHA ONLY)
    __Alpha_AXP (ALPHA ONLY)
    __32BITS
    __ia64 (I64 ONLY)
    __ia64__ (I64 ONLY)
Product name: vaxc __vaxc
  VAXC __VAXC
  vax11c __vax11c
  VAX11C __VAX11C
    __DECC
Standard C version of the compiler:   __STDC__ 1
Compiler is a hosted implementation   __STDC_HOSTED__ =1 for /STANDARD=c99 and /STANDARD=LATEST. __STDC_HOSTED__ not defined for all other /STANDARD keywords.
C99 or ISOC94 version of the compiler   __STDC_VERSION__ =199901L for /STANDARD keywords C99, LATEST, RELAXED, MS, PORTABLE. __STDC_VERSION__ =199409L when the ISOC94 keyword is specified alone or with the ANSI89, MIA, RELAXED, MS, PORTABLE, or COMMON modes. 2
ISO/IEC 10646   __STDC_ISO_10646__ =yyyymmL 3
MIA version of the compiler:   __MIA 4


1__STDC__ is defined to 1 for /STANDARD keywords ANSI89, C99, LATEST and MIA. It is defined to 2 for /STANDARD=RELAXED and to 0 for /STANDARD=MS. It is not defined for /STANDARD keywords VAXC and COMMON.
2Because C99 is a superset of Amendment 1 to the C89 standard, and the default mode of RELAXED is a superset of C99, __STDC_VERSION__ is defined with the C99-specified value of 199901L. Only when the ISOC94 keyword is added to the strict ANSI89, MIA, RELAXED, MS, COMMON, or PORTABLE modes does the macro take on the Amendment 1 value of 199409L. In the absence of the ISOC94 keyword, ANSI89, MIA, and COMMON modes do not define the macro at all.
3__STDC_ISO_10646__ evaluates to an integer constant of the form yyyymmL (for example, 199712L), intended to indicate that values of type wchar_t are the coded representations of the characters defined by ISO/IEC 10646, along with all amendments and technical corrigenda as of the specified year and month.
4__MIA is defined only in MIA mode.

Most of these macros are defined as 1 or 0, as appropriate to the processor and compilation qualifiers. Refer to the end of the compiler's source listing to see the names and values of all the macros that are defined prior to processing the first line of source code. The listing shows all macros predefined by the compiler, as well as those defined on the command line by the /DEFINE qualifier, but omits any that were undefined by the /UNDEFINE qualifier.

Note

Some users have tried defining the macro __ALPHA explicity with a /DEFINE qualifier or in a header file as a quick hack to deal with source-code conditionals that were written to assume that if __ALPHA is not defined, then the target must be a VAX. Doing this causes the CRTL headers and other OpenVMS headers to take the wrong path for I64 systems. Never define any of the Alpha architecture predefined macros when using the compiler on I64 systems.

You can use these system identification macros to separate portable and nonportable code in any of your HP C programs or to conditionally compile HP C programs used on more than one operating system to take advantage of system-specific features. For example:


#ifdef    VMS 
#include  rms           /* Include RMS definitions.  */ 
#endif 

See the HP C Language Reference Manual for more information about using the preprocessor conditional-compilation directives.

6.1.2.1 The __DECC_VER Macro

The __DECC_VER macro provides an integer encoding of the compiler version-identifier string that is suitable for use in a preprocessor #if expression, such that a larger number corresponds to a more recent version.

The format of the compiler version-identifier string is:


TMM.mm-eee

Where:

  • T is the version type (letter).
  • MM is the major version number.
  • mm is the update (minor version number).
  • eee is the edit suffix number.

The format of the integer encoding for __DECC_VER is:


vvuuteeee

Where:

  • vv is the major version number.
  • uu is the update (minor version number).
  • t is the numerical encoding of the alphabetic version type from the version-identifier string.
    Table 6-2 lists the possible version types and their encodings:

    Table 6-2 __DECC_VER Version-Type Encodings
    Type Numerical Encoding Description
    T 6 Field-test version
    S 8 Customer special
    V 9 Officially supported version

  • eeee is the edit suffix number.

The following describes how the __DECC_VER integer value is calculated from the compiler version-identifier string:

  1. The major version is multiplied by 10000000.
  2. The minor version (the digits between the '.' and any edit suffix) is multiplied by 100000 and added to the suffix value (The suffix value has a range of 0-999).
  3. If the character immediately preceding the first digit of the major version number is one of the ones listed in Table 6-2, its numerical encoding is multiplied by 10000.
  4. The preceding values are added together.

The following examples show how different compiler version-identifier strings map to __DECC_VER encodings:


ident           __DECC_VER 
string          vvuuteeee
 
T5.2-003   -->   50260003 
V6.0-001   -->   60090001 

6.1.2.2 The __VMS_VER Macro

The __VMS_VER macro provides an integer encoding of the OpenVMS version-identifier string that is suitable for use in a preprocessor #if expression, such that a larger number corresponds to a more recent version.

The format of the OpenVMS version-identifier string is:


TMM.mm-epp

Where:

  • T is the version type (letter).
  • MM is the major version number.
  • mm is the update (minor version number).
  • ee is the edit number.
  • pp is the patch letter.

The format of the integer encoding for __VMS_VER is:


vvuuepptt

Where:

  • vv is the major version.
  • uu is the update (minor version)
  • e is the edit number.
  • pp is the patch letter (A = 01, ..., Z = 26)
  • tt is the alphabetic ordinal of the version type from the version-identifier string (E = 05, ..., V = 22)
    Note that there are no version-type letters A - D and W - Z.

The following describes how the __VMS_VER integer value is calculated from the OpenVMS version-identifier string:

  1. The major version is multiplied by 10000000.
  2. The minor version (the digits between the '.' and any edit/patch suffix) is multiplied by 100000 and added to the suffix value.
    The suffix value is the optional edit number multiplied by 10000, added to the optional patch letter's alphabetic ordinal multiplied by 100.
  3. The preceding values are added together, along with the alphabetic ordinal of the version type.

The following examples show how different OpenVMS version-identifier strings map to __VMS_VER encodings:


ident           __VMS_VER 
string          vvuuepptt
 
V6.1      -->    60100022 
V6.1-1H   -->    60110822 
E6.2      -->    60200005  ("IFT") 
F6.2      -->    60200006  ("FT1") 
G6.2      -->    60200007  ("FT2") 
V6.2      -->    60200022 
T6.2-1H   -->    60210820 
V6.2-1I   -->    60210922 
V5.5-1H1  -->    50510822 (extra trailing digit ignored) 

6.1.3 Standards Conformance Macros

The HP C RTL contains functions whose support and syntax conform to various industry standards or levels of product or operating system support.

Table 6-3 lists macros that you can explicitly define (using the /DEFINE qualifier or the #define preprocessor directive) to control which HP C RTL functions are declared in header files and to obtain standards conformance checking.

Table 6-3 Standards Macros---All platforms
Macro Standard
_XOPEN_SOURCE_EXTENDED XPG4-UNIX
_XOPEN_SOURCE XPG4
_POSIX_C_SOURCE POSIX
_ANSI_C_SOURCE Standard C
_VMS_V6_SOURCE OpenVMS Version 6 compatibility
_DECC_V4_SOURCE DEC C Version 4.0 compatibility
_BSD44_CURSES 4.4BSD Curses
_VMS_CURSES VAX C Curses
_SOCKADDR_LEN 4.4BSD sockets

These macros, with the exception of _POSIX_C_SOURCE , can be defined to 0 or 1.

The _POSIX_C_SOURCE macro can be defined to one of the following values:

0
1
2
199506

See the HP C Run-Time Library Reference Manual for OpenVMS Systems for more information about these feature-test macros.

6.1.4 Floating-Point Macros

HP C for OpenVMS Systems automatically defines the following macros that pertain to the format of floating-point variables. They can be used to identify the format with which you are compiling your program.

  • __D_FLOAT
  • __G_FLOAT
  • __IEEE_FLOAT
  • _IEEE_FP
  • __X_FLOAT

One of the first three macros listed is defined to have a value of 1 when the corresponding option of the /FLOAT qualifier is specified, or the appropriate /[NO]G_FLOAT qualifier is used. (The /G_FLOAT qualifier is kept only for compatibility with VAX C.) If the corresponding option was not specified, the associated macro is defined to have a value of 0.

The _IEEE_FP macro is defined in any IEEE floating-point mode except FAST.

On OpenVMS Alpha and I64 systems, the __X_FLOAT macro is defined to have a value of 1 when /L_DOUBLE_SIZE=128 (the default), and a value of 0 when /L_DOUBLE_SIZE=64.

These macros can assist in writing code that executes conditionally, depending on whether the program is running using D_floating, G_floating, or IEEE_floating precision.

For example, if you compiled using G_floating format, then __D_FLOAT and __IEEE_FLOAT are predefined to be 0, and __G_FLOAT is predefined as if the following were included before every compilation unit:


#define  __G_FLOAT  1 

You can conditionally assign values to variables of type double without causing an error and without being certain of how much storage was allocated for the variable. For example, you may assign values to external variables as follows:


#ifdef __G_FLOAT  
double x = 0.12e308;        /* Range to 10 to the 308th power */ 
#else 
double x = 0.12e38;         /* Range to 10 to the 38th power  */ 
#endif 

All predefined macro names, such as __G_FLOAT , are reserved by HP.

You can remove the effect of predefined macro definitions by explicitly undefining the conflicting name. For more information about undefining macros, see the #undefine directive in the HP C Language Reference Manual. For more information about the G_floating representation of the double data type, see Chapter 4.


Previous Next Contents Index

Privacy statement Using this site means you accept its terms
© 2007 Hewlett-Packard Development Company, L.P.