1834454 Members
2948 Online
110067 Solutions
New Discussion

Re: Porting to 64 Bit

 
Maverick_2
Occasional Advisor

Porting to 64 Bit

Hi

We are migrating a 32 Bit C program to 64 Bit on HPUX 11i.

In our C App We are using some functions like

char * GetCFGValue(char & line)
{
char * pszStart = 0;
if ((pszStart = (char *)strchr(pszLine,
(int)'[')) != 0)
pszStart++;
return(pszStart);
}

We get a warning with the M1 Compiler options..

warning 724: Cast converts default int return type to pointer.

And our app crashes on runtime..

Appreciate your thoughts..

Thanks..
1 REPLY 1
rick jones
Honored Contributor

Re: Porting to 64 Bit

If I had to guess, I would say that you are not including the proper include files, and at some point someone kludged the code with that (char *) in front of the strchr to "fix" it.

It would have "worked" in 32 bit (aka ILP32) because an int (what C assumes a function returns unless told otherwise by a declaration) was the same size as a pointer. When you go 64-bit, you are in an "LP64" model where only longs and pointers are 64-bit, and ints remain 32-bit.

If you do a "man strchr" you can see the discussion of the include files for strchr. Then you should be able to get rid of that "char *) cast in front of strchr.

Or I could be barking up the wrong tree.
there is no rest for the wicked yet the virtuous have no pillows