Lazy evaluation of C++ static constructors

  • Authors:
  • Marc Sabatella

  • Affiliations:
  • -

  • Venue:
  • ACM SIGPLAN Notices
  • Year:
  • 1992

Quantified Score

Hi-index 0.00

Visualization

Abstract

Static constructors in C+ + are functions that are executed implicitly to initialize objects at run time. Although a C+ + implementation is allowed to defer the construction of objects defined in a given translation unit until the first use of any function or object defined in that translation unit, most implementations execute all static constructors for the entire program before the invocation of main(). In this paper, we describe an implementation that defers the execution of static constructors for objects defined by a translation unit in a shared library until the first potential access of any function or object defined in that translation unit. This design relies on the deferred dynamic binding facility provided by the HP-UX shared library implementations. We describe how to modify our design to apply to statically linked programs as well, while avoiding most of the overhead normally associated with dynamic linking.