> Okey, please give me how you proto-type declared StrToLL() function.
> 
> As for default, when you did not proto-type declare StrToLL()
> function, C compiler will treat StrToLL() as if it's being declared
> as:
> 
> int   StrToLL( int );
> 
> So, if you want LL to be returned, and char * to be passed, you MUST
> have the correct proto-type declaration like:
> 
> unsigned long long    StrToLL( char *str );

That is exactly how it is declared.  I have this in a header file.
That header file is included in the module that has the calling 
instruction.

I had a couple of problems that caused the problem.

The problem turned out to be related to doing math to calcualte
the LL value of x.  I was subtracting pointers then adding them
to x.  Apparently because I was adding pointers differences to
x, it converted x to L instead of LL, even though the proto-type
had the return value as LL.

I was using:
x = ((x * base) + (StrChr(a64, s[i]) - a64); to calculate x
which was declared as LL.  This returned the wrong value.

I changed it to:
x = ((x * base) + (unsigned long long)(StrChr(a64, s[i]) - a64);
and it then returned the LL value instead of L.

I would have thought that since x was declared as LL, then any
calculation assigned to x would automatically be LL.  But that 
was not true.


 
> # Some people beleave we can skip (char *str), but we shouldn't.
> # In unix, int is 32bit, which is exactly the size of pointer,
> # but this case, Palm's int is 16bits and pointer is 32.
> 
> 
> MSD> Can anyone shed light on this problem?  What is the solution?
> MSD> I cannot return LL values from a function.
> MSD> I cannot access LL values properly, if global.
> 
> I still can not point out the "Exact" point, because I can't see
> your exact C code. But I do beleave it's problem of declaration and
> function proto-typing.

This was one of the other problems.  When I was getting Zero, the
problem was because of a missing include directive.  But I fixed that
and still had a problem with x being returned as L instead of LL, the
cast, shown above, fixed that.

BTW, usually when I am missing an include, the linker will barf
at the function being called and indicate a Truncate to 16 bit or 
something like that.  In this case, the linker did not give any
warning.  Wierd.

Thanks to everyone who helped with this.
--
-----------------------------------------------------------------
Discussion Group:        http://www.halcyon.com/ipscone/wwwboard/

Protect your constitutional rights. Your favorite one may be next!
-----------------------------------------------------------------

Reply via email to