Re: proC function prototype bug

From: Mark Bluemel <markb_at_pyramid.com>
Date: 1995/06/07
Message-ID: <1995Jun7.102208.7020_at_pyra.co.uk>#1/1


Rob E. Allan (rallan_at_ohgpu.hydro.on.ca) wrote:
: I am starting to program some stuff using ProC v2.0.4.0.0 against
: a V7.14 database. I found an annoying bug and I was wondering if there
: is a bug fix for it.
 

: Here's the bug:
 

: If I have a function:
 

: int oraConnect(const char uid[50], const char pwd[50])
 

: And it does:
 

: EXEC SQL CONNECT :uid IDENTIFIED BY :pwd;
 

: It always returns an error. If I change the function prototype
: from char[50] to char*, everything works. It seems that the precompiler
: doesn't pick up the "50", it sets:
 

: sqlstm.sqhstl[1] = (unsigned int )1
 

: instead of:
 

: sqlstm.sqhstl[1] = (unsigned int )50
 

: If I define a char[50] array within the function, it works fine.

This is not so surprising - the size of an array argument to a function is not set by the function, but by the calling code. In general, the prototype would be better as :-

        int oraConnect(const char uid[], const char pwd[])

which makes it clear that the size of the array is set elsewhere.

I suppose you could argue that the C standard has a bug in allowing a size to be specified in this context, but Pro*C is behaving quite rationally - it sees an array argument and can have no knowledge of its size.

--
Mark Bluemel	Unix/Oracle Trainer and Consultant
		My opinions are my own, but I'll share them
		All solutions to problems are offered "as is"
		and without warranty - you have been warned :-)
Received on Wed Jun 07 1995 - 00:00:00 CEST

Original text of this message