Patrick Foley

Code Warrior C Compiler issue

Discussion created by Patrick Foley on Feb 18, 2009
Latest reply on Feb 20, 2009 by bigmac

I am wondering if anybody can tell me why the following code will not work????

 

 

First, I have a function that returns an unsigned long as follows.  This function works with no problem.

 

unsigned long GetSysMSec(void){
  return(SystemClock);
} //End unsigned long GetSysMSec(void)

 

 

The problem is when I try to implement the function in the following two ways.

 

1) assigning to a variable and adding an offset within the same line:

 

//This does not work 

DelayTime = GetSysMSec() + 2000;

 

//This works

DelayTime = GetSysMSec();

DelayTime += 2000;

 

 

DelayTime is a variable of type unsigned long.

 

2) using the function in a comparison statement:

 

if(DelayTime <= GetSysMSec()){
      //Do Things
}

 

For some reson this always evaluates to true, even when I set DelayTime to a value much greater than the return from GetSysMSec()

 

Any help would be appreciated,  I am not certain if there is a compiler setting I need to look at or if there is just an issue with the compiler itself.  The code I have shown above works just fine on other platforms like my Keil Compiler used on an 8051 core.

 

 

CodeWarrior information:

Code Warrior IDE version   5.9.0

Build                              2330

 

 

 

 

 

 

Message Edited by MagnaDon on 2009-02-18 05:35 PM

Outcomes