Hi Rob,

I'm guessing that you don't have a declaration (prototype) of your function
in a header file that's included by the source file that has the calling
function.  Without it, C will assume numbers need to be passed by int, which
are 16 bits long.  Thus, the number 69 is being treated as a 16-bit int,
that 16 bits is being pushed onto the stack, and then
DisplayMessageForABitOutsideApp (which is defined to accept a 32 bit value),
pulls 32 bits off of the stack such that your 16 bit value is in the upper
16 bits and garbage is in the lower 16 bits.

In some appropriate header, add:

   void DisplayMessageForABitOutsideApp(const char*, UInt32);

Include that header in the source file containing the calling function and
see if that helps.  Also, turn on the CodeWarrior warning that will tell you
when haven't properly declared your functions (Language Settings > C/C++
Language > Require Function Prototypes). :-)

-- Keith Rollin
-- Palm OS Developer Tools engineer

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rob
Sent: Wednesday, October 06, 2004 1:15 AM
To: Palm Developer Forum
Subject: Am I missing something?

Am I allowed to pass a value in a function call that is hard coded rather
than in a variable?

If I do this:

        {
        UInt32  delay=69;       
        
        if (passedDataP->switchMode)
                DisplayMessageForABitOutsideApp("Switch Mode",delay);
        else
                DisplayMessageForABitOutsideApp("Scroll Mode",delay);
        }

then the value 69 is passed to my function

however if I do this

        {
        //UInt32        delay=69;       
        
        if (passedDataP->switchMode)
                DisplayMessageForABitOutsideApp("Switch Mode",69);
        else
                DisplayMessageForABitOutsideApp("Scroll Mode",69);
        }


then the value 4521984 is passed (seems to be shifted by 16 bits)

The function is defined in a seperate file and I've included the header in
my main file

I'm using codewarrior 9.?

What am I doing wrong?


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to