Re: VARCHAR problems with string functions on HP-UX

From: Tommy Wareing <p0070621_at_oxford-brookes.ac.uk>
Date: 1 Oct 1993 04:08:51 -0500
Message-ID: <CE7nyu.4Gz_at_uk.ac.brookes>


lee m godfrey nmtr stnt (lmg2411_at_hertz.njit.edu) wrote:
> When compiling Pro*C programs under HP-UX v9.01, the compiler issues
> warnings if a VARCHAR .arr element is passed to a string function.
> I am compiling with the -Aa option.
> ex:
> VARCHAR username[20];
> char uname[20];
> strcpy(uname,username.arr);

I hope you remembered to put the trailing NULL onto the array before use. The error's because VARCHARs use UNSIGNED chars, but the normal char is SIGNED.
> The program will run, but I'd like to eliminate the warnings. I
> have tried casting the VARCHAR .arr as (char *) which works,
> but I'm porting a large application from VAX/VMS and would prefer
> a global solution. So far, experimenting with MODE and CODE
> precompiler options has been unsuccessful.

I gave up on this one (someone may tell me how wrong I am...) I now use
EXEC SQL BEGIN DECLARE SECTION;
char username[20];
EXEC SQL VAR username IS STRING;
EXEC SQL END DECLARE SECTION; This tells the pre-compiler that username is upto 19 characters followed by a trailing NULL. And all the string functions work! (And you don't have to muck around with that irritating little .len field either :)

--
  _________________________   _________________________________________
 /  Tommy Wareing          \ /  And I dream of movies                  \
|  p0070621_at_brookes.ac.uk   X   They won't make about me when I'm dead  |
 \  0865-483389            / \      - Jon Bon Jovi, Keep the Faith     /
  ~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Fri Oct 01 1993 - 10:08:51 CET

Original text of this message