DECLARE(2)

Table of Contents

Name

declare declarations for the main program of an SDTool

Synopsis

%declare
C declarations and procedures

Description

The declare section of a source description file contains a set of C declarations and procedures that are added to the generated main.c file. The C code in the startcode, middlecode, finalcode, option and product sections have access to these declarations. Product description files do not automatically have access to these declarations. Use a header section for declarations that are used by both the source and product description files, and use the product description file's declare section for declarations used by only one product description file. For global variables, place the extern definitions in the header section and the declarations in the declare section. To avoid name conflicts, use static definitions for local variables to the main program.

Example

%grammar
files: ( xfile+ )
x ( name:<[a-z]+> num:INT = ++count; ) %header
extern int count;
%declare

int count;
/* global name */
static int count2;
/* local name */ %startcode count = 0; count2 = 0; %middlecode count2 = subcount(); /* a count computed by subcount */ reportinfo("There are %d files in the input.\n",count);

See Also

HEADER(2)
DECLARE(3)


© 1990 Lucent Technologies, Inc
© 1998 Harmony Software, Inc