Re: why are Oracle Pro*C examples K&R not ANSI?

From: Kenneth C Stahl <BlueSax_at_Unforgettable.com>
Date: Mon, 06 Dec 1999 07:54:00 -0500
Message-ID: <384BB1E8.1FCE5325_at_Unforgettable.com>


Clint Eastwood wrote:
>
> HIYa
>
> I was reading some O manuals recently and came across this example,
> which I thought wasn't kocher anymore... no?
>
> void
> sql_error(msg)
> char *msg;
> {
> char err_msg[128];
> int buf_len, msg_len;
>
> EXEC SQL WHENEVER SQLERROR CONTINUE;
>
> printf("\n%s\n", msg);
> buf_len = sizeof (err_msg);
> sqlglm(err_msg, &buf_len, &msg_len);
> printf("%.*s\n", msg_len, err_msg);
>
> EXEC SQL ROLLBACK RELEASE;
> exit(1);
> }
>

This is a very tricky question in some ways.

In this day and age, all code should be developed to ANSI/ISO standards - without exception. However, if you read oracle documentation long enough you'll come across a recommendation that programs be compiled with the -Xa option (which is the default with many compilers). The -Xa option accepts all ANSI/ISO syntax, but if it comes across a K&R construct it will just silently compile it. I've even seen some cases where it appears that behind the scenes it rearranges the code to be ANSI complient and then parses for the cX-Mozilla-Status: 0009te me on that.

The temptation, of course is to use -Xc - and that will probably blow up on you in many cases because there are a lot more hoops you must jump through to write thoroughly complient code. Received on Mon Dec 06 1999 - 13:54:00 CET

Original text of this message