HP OpenVMS Systems

ask the wizard
Content starts here

VAX C, global sections, and alignment?

» close window

The Question is:

 
Is it possible to build an image linked with a VAXC OLB
and execute it on a VAX running VMS 5.5-2H4 with DECC RTL
installed? We have tried this and have found that global
sections mapped by the VAXC - bound application are not
aligned properly. We are trying to avoid rebuilding the
application with the DECC compiler.
 


The Answer is :

 
  VAX C and Compaq (DEC) C are fully compatible, and can be installed
  coresident, and can operate on the same OpenVMS VAX system.  Compaq
  (DEC) C can be installed on OpenVMS VAX V5.5-2 through V6.0 (inclusive),
  with the installation of the Compaq (DEC) C run-time library kit provided
  with the compiler.  The Compaq (DEC) C run-time kit is not required on
  OpenVMS VAX V6.1 and later, nor on OpenVMS Alpha V6.1 and later.
 
  The Wizard would strongly encourage the use of Compaq (DEC) C over VAX C,
  as it is far better at finding latent problems in C source code, and it
  makes for far easier porting of C code to Compaq (DEC) C on OpenVMS Alpha
  or to other ANSI C platforms.  Compaq (DEC) C also supports a VAX C
  compatibility mode.
 
  As for alignment questions involving installed images, that does not
  appear to be directly tied to the use of an object library (OLB).  The
  Wizard would recommed the use of shareable images for VAX C or Compaq
  (DEC) C, over the use of a compiler object library.  For information on
  creating shareable images -- and why you might want to -- please see the
  pointer to the shareable image cookbook included in the OpenVMS Frequently
  Asked Questions (FAQ).
 
  The initial Compaq (DEC) C compiler command first used when porting many
  VAX C programs to Compaq (DEC) C is:
 
    $ CC/DECC/STANDARD=VAXC/PREFIX=ALL
 
  For additional information on using global sections from C, see the
  global section programming example available at the OpenVMS Ask The
  Wizard website.
 
  The Wizard could infer from the question that the application may be
  overmapping a program data structure with a global section -- this is
  similar to a Fortran COMMON, and is not an approach that the Wizard
  would recommend.  For reasons of flexibility and adaptability, and
  to avoid frequent relinking when constituent shareable images change
  sizes, the Wizard prefers to use dynamic, run-time, position-independent
  global section over a link-time position-dependent COMMON -- global
  sections can be mapped into the next available memory, and the program
  can control the size of the global section as required.  COMMONs are
  static, and image(s) must be periodically relinked.  (Be aware that
  position independence means that you cannot store virtual addresses
  in a section, you must store base-relative offsets -- offsets from the
  base address of the global section -- in any data structures present
  in the section.  This "referencing" and "dereferencing" is required
  as the global section is position-independent; the section may not be
  mapped into the same portion of virtual address space in each process
  accessing it.)  When working with commons and particularly with extern
  externals, also see the /SHARE_GLOBAL and /EXTERN_MODE=COMMON_BLOCK
  Compaq (DEC) C command qualifiers.
 
  Also see the member alignment pragmas and the /MEMBER_ALIGNMENT compiler
  qualifier.  Compaq (DEC) on OpenVMS VAX uses byte alignment, while
  Compaq (DEC) C on OpenVMS Alpha uses natural alignment.  (OpenVMS Alpha
  is particularly sensitive to memory aligment.)  This difference is not
  usually a problem, save for specific cases such as sharing of data
  structures between OpenVMS VAX and OpenVMS Alpha systems (eg: network
  packets or RMS file records), or for OpenVMS Alpha structures that
  must explicitly be unaligned (eg: the process quota list array on the
  sys$creprc system service).  When the data structure must have a
  particular member alignment, use the #pragma [no]member_alignment.
 
  Compaq (DEC) C also assumes that string literals are not writeable,
  where some C programs assume these "constants" can be written.  To
  assist in porting this code, see the /ASSUME=WRITABLE_STRING_LITERALS
  qualifier.
 
  For specific information on the "not aligned properly" problem that is
  being reported, please contact the customer support center -- there is
  insufficient information on the error and on the application included
  with the report to provide an answer with any degree of certainty.
 

answer written or last revised on ( 25-OCT-1999 )

» close window