Re: Pro*C Variables and Define Tokens

From: Steven F. LeBrun <lebrun_at_ll.mit.edu>
Date: Thu, 24 Sep 92 12:19:18 -0400
Message-ID: <9209241219.PN26301_at_LL.MIT.EDU>


   In article <1992Sep22.175344.5214_at_cbfsb.cb.att.com> gerette_at_cbnewsb.cb.att.com (marianne.g.pittorino) writes:

>>
>>I am having trouble declaring Pro*C variables using #define tokens. In my
>>(UNIX) application, we have an include header file that has #define tokens
>>for all our data elements. When declaring a 'C' or database variable, we
>>always use the #define token. For example, if a customer name variable were
>>needed, we code:
>>
>> char custname[CUSTNAME_SZ + 1]; /* add one for NULL byte */
>>
 ...
>>Precompiling x.pc
>> 20 VARCHAR custname[CUSTNAME_SZ + 1];
>> 20 ........................^
>> PCC-S-0018: Expected "<unsigned_integer>", but found "CUSTNAME_SZ" at
>> line 20 in file x.pc
 ...
>> What I cannot believe is that the Pro*C precompiler cannot recognize
>>#define tokens (and, by the way, it balks at the "+" sign as well). This is
>>very important to our application; it took many months to standardize all our
>>code with the #define tokens. Does anyone know how to get this to work?
>>
>>
>>
>>Marianne

In article <1992Sep24.121138.6821_at_cs.umb.edu> pytlik_at_ra.cs.umb.edu (Marek Pytlik) writes:

>To make this work, before precompilation, put the code thru preprocessor.
>
>   Mark

Unfortunately, running Pro*C code through the preprocessor before running it throught the Pro*C precompiler can results in problems. Remember that in C, NULL is a macro. In Embedded SQL, NULL is a keyword.

Running Pro*C code through a preprocessor will result in all SQL NULL's being translated into to your local C definition of the macro NULL which will not be a NULL to SQL.

Also, considering that the Pro*C precompiler is really just making text substitution (One Embedded SQL Statement into a set of C code) I do not understand why the precompiler requires a numeric literal (constant) where a macro constant should suffice. If you look at the C code generated by the Pro*C precompiler, it just plugs in the numbers it gets from expressions like `VARCHAR xxx[123]' directly into function calls and variable definitions. I always got the impression, when dealing with Pro*C precompiler, that I was working with a program that is treating C code as if it was FORTRAN (pre parameter statement Fortran).

--

+--------------------------------------------------------------------------+
| Steven F. LeBrun             |      MIT Lincoln Laboratory, Group 91     |
|                              |        244 Wood Street, Room LI-136       |
| lebrun_at_ll.mit.edu (Internet) |          Lexington, MA 02173-9108         |
| lebruns_at_merlin    (internal) |  Phone:(617)-981-5742, FAX:(617)-981-0991 |
 +--------------------------------------------------------------------------+
|"Hard as lightning, soft as candlelight;                                  |
|                    Dare you trust the Music of the Night?" - The Phantom |
 +--------------------------------------------------------------------------+
Received on Thu Sep 24 1992 - 18:19:18 CEST

Original text of this message