Browse Prior Art Database

Compiled Constants made Available from Outside an Application

IP.com Disclosure Number: IPCOM000109003D
Original Publication Date: 1992-Jul-01
Included in the Prior Art Database: 2005-Mar-23
Document File: 2 page(s) / 78K

Publishing Venue

IBM

Related People

Beaty, KA: AUTHOR [+2]

Abstract

This article deals with the problem of making constants defined in applications written using a compiled language known outside the application. Prior to compilation the constant is described by a name and a value; after compilation, it is defined by a location and a value. Since the name of the constant constitutes its identification, losing it during compilation makes it impossible to find and use the constants and their values. It is important for the external environment to gain access to these constants, as they are often used on input to functions that may be called as external routines, or on output from these same functions.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

Compiled Constants made Available from Outside an Application

       This article deals with the problem of making constants
defined in applications written using a compiled language known
outside the application.  Prior to compilation the constant is
described by a name and a value; after compilation, it is defined by
a location and a value.  Since the name of the constant constitutes
its identification, losing it during compilation makes it impossible
to find and use the constants and their values.  It is important for
the external environment to gain access to these constants, as they
are often used on input to functions that may be called as external
routines, or on output from these same functions.

      To solve this problem, maintain the constants in a table in the
compiled program, accessible to the external programs trying to use
the application.  This table must contain one entry for each
constant.  Each entry must contain the following information:
       .   Constant name (normally the same name as used in a C
#define statement, although this is no requirement)
       .   Constant type (e.g., Integer, Boolean, String, etc.)
       .   Constant value

      If the programming language used to create the application is
C, then the following macro can be used to facilitate the creation of
entries into the table:
      #define Crow(id,type) {#id, type, id}
The advantage of using this macro to define the table entry is that
both the value and the name of the constant is derived from the id
field.  Thus, if the value changed, the change will be picked up
automatically the next time the file is compiled.

      Once the table of constants has been defined, it will maintain
the names, types and values of the constants.  The external program
can then either load all of the constants from the table, or do a
selective load based on matching the name of the needed constant with
the name field of the table and then extracting the value.  In either
case the constant will be available for use outside the de...