United States    
COMPAQ STORE | PRODUCTS |
SERVICES | SUPPORT | CONTACT US | SEARCH
Compaq C

Compaq C
User's Guide for OpenVMS Systems


Previous Contents Index

5.4.12.2 #pragma message option2

The parameter option2 must be one of the following keywords:

The save and restore options are useful primarily within header files.

5.4.12.3 #pragma message (quoted-string)

This form of #pragma message is provided for compatibility with Microsoft's #pragma message directive.

The #pragma message (quoted-string) form of this directive emits the specified string as a compiler message. For example, when the compiler encounters the following line in the source file:


#pragma message ("hello") 

It emits:


#pragma message ("hello") 
................^ 
%CC-I-SIMPLEMESSAGE, hello 
at line number 1 in file DISK1$:[SMITH]TEST.C;1 

This form of the pragma is subject to macro replacement. For example, the following is allowed:


#pragma message ("Compiling file " __FILE__) 

5.4.13 #pragma module Directive

When you compile source files to create an object file, the compiler assigns the first of the file names specified in the compilation unit to the name of the object file. The compiler adds the .OBJ file extension to the object file. Internally, the OpenVMS system (the debugger and the librarian) recognizes the object module by the file name; the compiler also gives the module a version number of 1. For example, given the object file EXAMPLE.OBJ, the debugger recognizes the EXAMPLE object module.

To change the system-recognized module name and version number, use the #pragma module directive. The #pragma module directive is specific to Compaq C for OpenVMS systems and is not portable.

You can find the module name and the module version number listed in the compiler listing file and the linker load map.

The #pragma module directive is equivalent to the VAX C compatible #module directive. The #pragma module directive may be used when compiling in any mode. Use #module only when compiling with the /STANDARD=VAXC qualifier.

The #pragma module directive has the following formats:

#pragma module identifier identifier
#pragma module identifier string

The first parameter must be a valid Compaq C identifier. It specifies the module name to be used by the linker. The second parameter specifies the optional identification that appears on listings and in the object file. It must be either a valid Compaq C identifier of 31 characters or less, or a character-string constant of 31 characters or less.

Only one #pragma module directive can be processed per compilation unit, and that directive must appear before any C language text. The #pragma module directive can follow other directives, such as #define , but it must precede any function definitions or external data definitions.

The parameters in a #pragma module directive are subject to text replacement and can, therefore, contain references to identifiers defined in previous #define directives. The replacement occurs before the parameters are processed.

5.4.14 #pragma optimize Directive (ALPHA ONLY)

The #pragma optimize preprocessor directive sets the optimization characteristics of function definitions that follow the directive. It allows optimization-control options that are normally set on the command line for the entire compilation to be specified in the source file for individual functions.

The #pragma optimize directive has the following format:

#pragma optimize settings
#pragma optimize save
#pragma optimize restore

Where settings is any combination of the following:

Whitespace is optional between the setting clauses and before and after the "=" in each clause. The pragma is not subject to macro replacement.

For more information on the optimization settings, see Table 1-15 in the description of the /OPTIMIZE qualifier in Section 1.3.4.

Example:


#pragma optimize level=5 unroll=6 

The save and restore options save and restore the current optimization state (level, unroll count, ansi-alias setting, and intrinsic setting).

Usage Notes

  • If the level=0 clause is present, it must be the only clause present.
  • The #pragma optimize directive must appear at file scope, outside any function body.
  • The #pragma environment save and restore operations include the optimization state.
  • The #pragma environment command_line directive resets the optimization state to that specified on the command line.
  • If #pragma optimize does not specify a setting for one of the optimization states, that state remains unchanged.
  • When a function definition is encountered, it is compiled using the optimization settings that are current at that point in the source.
  • When a function is compiled under level=0, the compiler will not inline that function. In general, when functions are inlined, the inlined code is optimized using the optimization controls in effect at the call site instead of using the optimization controls specified for the function being inlined.
  • When the OpenVMS command line specifies /NOOPT (or /OPTIMIZE= LEVEL=0), the #pragma optimize directive has no effect (except that its arguments are still validated).
  • The #pragma optimize directive controls most, but not all, optimizations performed by the compiler. Therefore, there can be some differences between setting the optimization using the pragma compared with using the /OPTIMIZE command-line qualifier.

5.4.15 #pragma pack Directive

The #pragma pack preprocessor directive specifies the byte boundary for packing members of C structures.

The #pragma pack directive has the following format:

#pragma pack [n]

The n specifies the new alignment restriction in bytes:
1 align to byte
2 align to word
4 align to longword
8 align to quadword
16 align to octaword

A structure member is aligned to either the alignment specified by #pragma pack or the alignment determined by the size of the structure member, whichever is smaller. For example, a short variable in a structure gets byte-aligned if #pragma pack 1 is specified. If #pragma pack 2 , 4 , or 8 is specified, the short variable in the structure gets aligned to word.

If #pragma pack is not used or if it is specified without the n, packing defaults to 16 on OpenVMS Alpha systems, and to 1 (byte alignment) on OpenVMS VAX systems.

5.4.16 #pragma pointer_size Directive (ALPHA ONLY)

The #pragma pointer_size preprocessor directive can be used throughout a program to control whether pointers are 32-bit pointers or 64-bit pointers.

This directive has the same effect as the #pragma required_pointer_size directive, except that #pragma pointer_size is enabled only when the /POINTER_SIZE command-line qualifier is specified. If /POINTER_SIZE is omitted from the command line, #pragma pointer_size is ignored. (The #pragma required_pointer_size directive always takes effect, whether or not /POINTER_SIZE is specified.)

The #pragma pointer_size directive has the following format:

#pragma pointer_size keyword

The keyword is one of the following:
{ short |32} 32-bit pointer
{ long |64} 64-bit pointer
system_default 32-bit pointers on OpenVMS systems; 64-bit pointers on Tru64 UNIX systems
save Saves the current pointer size
restore Restores the current pointer size to its last saved state

Notes

  • The #pragma pointer_size and #pragma required_pointer_size directives only affect the meaning of the pointer-declarator (*) in declarations, casts, and the sizeof operator.
  • The size of a pointer is the property of the type, and so it is bound in a typedef declaration, but not in a preprocessor macro definition.
  • The size of a pointer produced by the & operator, or by an array name or function name in a context where it is converted to an explicit pointer, is 32 bits unless the & operator is applied to an object designated by a dereference of a pointer having a 64-bit pointer type.

5.4.17 #pragma required_pointer_size Directive (ALPHA ONLY)

The #pragma required_pointer_size preprocessor directive is intended for use by developers of header files to control the size of pointers within a header file in those cases where the pointers are architecturally required to be a particular size, and must not be altered by the user's use of pointer-size controls.

This directive has the same effect as the #pragma pointer_size directive, except that a #pragma required_pointer_size always takes effect, even if /POINTER_SIZE is omitted from the command line. (The #pragma pointer_size directive is ignored if /POINTER_SIZE is omitted.)

The #pragma required_pointer_size directive has the following format:

#pragma required_pointer_size keyword

The keyword is one of the following:
{ short |32} 32-bit pointer
{ long |64} 64-bit pointer
system_default 32-bit pointers on OpenVMS systems; 64-bit pointers on Tru64 UNIX systems
save Saves the current pointer size
restore Restores the current pointer size to its last saved state

Notes

  • The #pragma pointer_size and #pragma required_pointer_size directives only affect the meaning of the pointer-declarator (*) in declarations, casts, and the sizeof operator.
  • The size of a pointer is the property of the type, and so it is bound in a typedef declaration, but not in a preprocessor macro definition.
  • The size of a pointer produced by the & operator, or by an array name or function name in a context where it is converted to an explicit pointer, is 32 bits unless the & operator is applied to an object designated by a dereference of a pointer having a 64-bit pointer type.

5.4.18 #pragma [no]standard Directive

Use the nostandard and standard pragmas together to define regions of source code where portability diagnostics are not to be issued.

This pragma has the following format:

#pragma [no]standard

Use #pragma nostandard to suppress diagnostics about non-ANSI extensions, regardless of the /STANDARD qualifier specified.

Use #pragma standard to direct the compiler to reinstate the setting of the /STANDARD qualifier that was in effect before the last #pragma nostandard was encountered. Every #pragma standard directive must be preceded by a corresponding #pragma nostandard directive.

The following example demonstrates the use of these pragmas:


#include <stdio.h> 
#pragma nostandard 
extern noshare FILE *stdin, *stdout, *stderr; 
#pragma standard 

In this example, nostandard prevents the NOSHAREEXT diagnostic from being issued against the noshare storage-class modifier, which is specific to Compaq C for OpenVMS systems.

Note

This pragma does not change the current mode of the compiler or enable any extensions not already supported in that mode.

5.4.19 #pragma use_linkage Directive (ALPHA ONLY)

After defining a special linkage using the #pragma linkage directive, described in Section 5.4.10, 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.


Previous Next Contents Index
  

1.800.AT.COMPAQ

privacy and legal statement