Re: Pro*C Variables and Define Tokens

From: Marek Pytlik <>
Date: 25 Sep 92 11:54:29 GMT
Message-ID: <>

In article <9209241219.PN26301_at_LL.MIT.EDU> (Steven F. LeBrun) writes:
> In article <> (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?
>In article <> (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
>| Steven F. LeBrun | MIT Lincoln Laboratory, Group 91 |
>| | 244 Wood Street, Room LI-136 |
>| (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 |

Work aroud the NULL problems is to use null instead of NULL in your sql code. I do not have explanation for the second issue.

Mark Received on Fri Sep 25 1992 - 13:54:29 CEST

Original text of this message