DEC C
User's Guide for OpenVMS Systems


Previous Contents Index

5.4.10 #pragma [no]member_alignment Directive

By default, DEC C for OpenVMS VAX systems does not align structure members on natural boundaries; they are stored on byte boundaries (with the exception of bit-field members).

By default, DEC C for OpenVMS Alpha systems does align structure members on natural boundaries.

The #pragma member_alignment preprocessor directive can be used to force natural-boundary alignment of structure members. The #pragma nomember_alignment preprocessor directive restores byte-alignment of structure members.

This pragma has the following formats:

#pragma member_alignment
#pragma member_alignment save
#pragma member_alignment restore
#pragma nomember_alignment [base_alignment]

When #pragma member_alignment is used, the compiler aligns structure members on the next boundary appropriate to the type of the member, rather than on the next byte. For example, a long variable is aligned on the next longword boundary; a short variable is aligned on the next word boundary.

Consider the following example:


#pragma nomember_alignment 
 
struct x { 
           char c; 
           int b; 
           }; 
 
#pragma member_alignment 
 
struct y { 
          char c;       /*3 bytes of filler follow c */ 
          int b; 
          }; 
 
main () 
 
{ 
        printf( "The sizeof y is: %d\n", sizeof (struct y) ); 
        printf( "The sizeof x is: %d\n", sizeof (struct x) ); 
} 
 

When this example is executed, it shows the difference between #pragma member_alignment and #pragma nomember_alignment .

Once used, the member_alignment pragma remains in effect until the nomember_alignment pragma is encountered; the reverse is also true.

The optional base_alignment parameter can be used to specify the base-alignment of the structure. Use one of the following keywords for the base_alignment:

The #pragma member_alignment save and #pragma member_alignment restore directives can be used to save the current state of the member_alignment and to restore the previous state, respectively. This feature is necessary for writing header files that require member_alignment or nomember_alignment , or that require inclusion in a member_alignment that is already set.

5.4.11 #pragma message Directive

The #pragma message directive controls the issuance of individual diagnostic messages or groups of messages. Use of this pragma overrides any command-line options that may affect the issuance of messages.

The #pragma message directive has the following formats:

#pragma message option1 (message-list)
#pragma message option2

The parameter option1 must be one of the following keywords:

The message-list can be any one of the following:

The parameter option2 must be one of the following keywords:

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

5.4.12 #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 DEC 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 DEC 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 DEC 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.13 #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.14 #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 DIGITAL 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.15 #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 DIGITAL 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.16 #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 DEC 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.17 #pragma use_linkage Directive (ALPHA ONLY)

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

This pragma has the following format:

#pragma use_linkage linkage-name (routine1, routine2, ...)

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

routine1, routine2, ... are the names of functions that you want associated with 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.

The following 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:


#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); 
} 

In this example, 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.


Previous Next Contents Index