Re: Pro*C/ANSI C/KNR C

From: Tim Smith <tssmith_at_netcom.com>
Date: Sun, 15 Aug 1993 00:43:31 GMT
Message-ID: <tssmithCBrzCJ.LIM_at_netcom.com>


In article <dmichel.745340325_at_afit.af.mil> dmichel_at_afit.af.mil (Douglas T Michel) writes:
>I have a simple question regarding Pro*C that I would
>like to clear up. Many of the people I work with
>tell me that Pro*C works only with KNR C. I don't
>think this is the case.
>
>Does the Pro*C pre-compiler care if the C is
>ANSI or KNR?

Yes and no. There is a command line switch CODE which determines whether Pro*C _generates_ ANSI compatible C code, or old style K&R C.

As far as your Pro*C program goes, there is one notable case in which you cannot use ANSI C-style coding. Suppose you have a function get_sal() that takes an argument emp_sal, and that argument is a host variable (used in a SQL statement).

Following ANSI C, you'd like to be able to define the function as:

void get_sal(float emp_sal)
{

    exec sql select sal into :emp_sal from emp where empno = 7499; }

but this won't work for Pro*C versions earlier than 2.0. The reason is that host variables must be declared in a Declare Section. So you have to code

void get_sal(emp_sal)
exec sql begin declare section;
  float emp_sal;
exec sql end declare section;
{

    exec sql select sal into :emp_sal from emp where empno = 7499; }

That is, you use the K&R function definition syntax, surrounding any host variables in the arg list with the Declare Section statements.

With Pro*C V2.0, due out with 7.1, the Declare Section is optional (when MODE=ORACLE), so you can use the ANSI C style definition syntax.

This case aside, you can use ANSI C syntax in your Pro*C program.

--Tim (tssmith_at_oracle.com) Received on Sun Aug 15 1993 - 02:43:31 CEST

Original text of this message