Operating System - HP-UX
1753969 Members
7214 Online
108811 Solutions
New Discussion юеВ

Re: Migrating source code from 32 to 64 bits

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: Migrating source code from 32 to 64 bits

>I have a 'long field' variable, and on another side i get, via Oracle SQLDA structures, data from my DB. Look at this line:

This is not a long in your database. This is an int32_t. You should get used to using explicit sizes in your port, especially if you have existing data files.

>field = *(long*)std_outp->V[0];
>it's a conversion from 'char**' to 'long'.

Why do you think this is a char**? Is V a char***?

>compiled under 64 bits, it gives me:
> std_outp->V[0] = '989999'
> field = 4252013328072704

You should debug this by printing both in hex.

>I find this conversion, via 'int', something 'horrible', I think that there has to be another way more 'beautiful' to do the cast.

Cast to int32_t*.
Chanquete
Occasional Advisor

Re: Migrating source code from 32 to 64 bits

Hi!
Sorry, but i was a bit lost. Re-reading my question i realize than i was explaining so horrible. I was mixing concepts.
Well, SQLDA->V is a char**:
struct SQLDA {
/* ub4 */ int N;
/* text** */ char **V;
/* ub4* */ int *L;
/* sb2* */ short *T;
/* sb2** */ short **I;
/* sb4 */ int F;
/* text** */ char **S;
/* ub2* */ short *M;
/* ub2* */ short *C;
/* text** */ char **X;
/* ub2* */ short *Y;
/* ub2* */ short *Z;
};

In an Oracle's example, it uses also this cast (to convert to '%d' value to printf):
*(int *)select_dp->V[i]
when the field has a NUMBER value.

If Oracle does it, i'll do it.

Thanks a lot!
Dennis Handly
Acclaimed Contributor

Re: Migrating source code from 32 to 64 bits

>SQLDA->V is a char**:

So V[0] is a char* and you were converting a char* to a long*, then dereferencing it.
Chanquete
Occasional Advisor

Re: Migrating source code from 32 to 64 bits

Oh, sorry, Dennis. You're so right!
But i have important news: my customer hear my words (i'm influential...) and we discard at the moment migrate the application to 64-bit.
And now we have a trouble:
Anybody knows something about the future of 32-bit in HP-UX? If the HP's future plan is not include 32-bit compatibility, we can think about 64-bit porting.
Thanks a lot, people!
Dennis Handly
Acclaimed Contributor

Re: Migrating source code from 32 to 64 bits

>Anybody knows something about the future of 32-bit in HP-UX? If the HP's future plan is not include 32-bit compatibility

There are no current plans to change this.
Perhaps when there are 128 bit computers. :-)