Using gpre

From InterBase
Jump to: navigation, search

Go Up to Preprocessing


The syntax for gpre is:

gpre [-language] [-options] infile [outfile]

The infile argument specifies the name of the input file.

The optional outfile argument specifies the name of the output file. If no file is specified, gpre sends its output to a file with the same name as the input file, with an extension depending on the language of the input file.

gpre has switches that allow you to specify the language of the source program and a number of other options. You can place the switches either before or after the input and output file specification. Each switch must include at least a hyphen preceded by a space and a unique character specifying the switch.


Language Switches

The language switch specifies the language of the source program. C and C++ are languages available on all platforms. The switches are shown in the following table:

Switch Language

-c

C

-cxx

C++

In addition, some platforms support other languages if an additional InterBase license for the language is purchased. The following table lists the available languages and the corresponding switches:

Switch Language

-al[sys]

Ada (Alsys)

-a[da]

Ada (VERDIX, VMS, Telesoft)

-ansi

ANSI-85 COBOL

-co[bol]

COBOL

-f[ortran]

FORTRAN

-pa[scal]

Pascal

For example, to preprocess a C program called census.e, type:

gpre -c census.e


Option Switches

The option switches specify preprocessing options. The following table describes the available switches:

gpre option switches
Switch Description

-charset <name>

Determines the active character set at compile time, where <name> is the character set name.

-d[atabase] <filename>

Declares a database for programs. <filename> is the file name of the database to access. Use this option if a program contains SQL statements and does not attach to the database itself. Do not use this option if the program includes a database­ declaration.

-d_float

VAX/VMS only. Specifies that double-precision data will be passed from the application in D_FLOAT format and stored in the database in G_FLOAT format. Data comparisons within the database will be performed in G_FLOAT format. Data returned to the application from the database will be in D_FLOAT format.

-e[ither_case]

Enables gpre to recognize both uppercase and lowercase. Use the -either_case switch whenever SQL keywords appear in code in lowercase letters. If case is mixed, and this switch is not used, gpre cannot process the input file. This switch is not
necessary with languages other than C, since they are case-insensitive.

-m[anual]

Suppresses the automatic generation of transactions. Use the
-m switch for SQL programs that perform their own transaction handling, and for all DSQL programs that must, by definition, explicitly control their own transactions.

-n[o_lines]

Suppresses line numbers for C programs.

-o[utput]

Directs the output of gpre to standard output, rather than to a file.

-password <password>

Specifies <password>, the database password, if the program ­connects to a database that requires one.

-r[aw]

Prints BLR as raw numbers, rather than as their mnemonic equivalents. This option can be useful for making the gpre ­output file smaller; however, it will be unreadable.

-sql_dialect

Sets the SQL dialect. Valid values are 1, 2, and 3.

-user <username>

Specifies <username>, the database user name, if the program connects to a database that requires one.

-x <handle>

Gives the database handle identified with the -database option an external declaration. This option directs the program to pick up a global declaration from another linked module. Use only if the -d switch is also used.

-z

Prints the version number of gpre and the version number of all declared databases. These databases can be declared either in the program or with the -database switch.

For sites with the appropriate license and are using a language other than C, additional gpre options can be specified, as described in the following table:

Language-specific gpre option switches
Switch Description

-h[andles] <pkg>

Specifies, <pkg>, an Ada handles package.


Examples of Using gpre

The following command preprocesses a C program in a file named appl1.e. The output file will be appl1.c. Since no database is specified, the source code must connect to the database.

gpre -c appl1

The following command is the same as the previous, except that it does not assume the source code opens a database, instead, explicitly declaring the database, mydb.ib:

gpre -c appl1 -d mydb.ib

Advance To: