cancel
Showing results for 
Search instead for 
Did you mean: 

ST92F150 compiler

scott239955
Associate II
Posted on January 06, 2004 at 00:50

ST92F150 compiler

4 REPLIES 4
scott239955
Associate II
Posted on May 17, 2011 at 11:35

I have been having a problem with the compiler. Has anyone else noticed something like this?

Problem-1:

A function I2C_IsBusy() returns a one if it is busy, zero otherwise. Sometimes when it returns 0, it may not continue on and will loop on itself forever. This seems to depend on where the function is called.

Problem-2:

The function bellow may receive 0 for length instead of 4 depending on where the function is called:

c = I2C_RdEE(4);

unsigned char I2C_RdEE (unsigned char length)

I2C_RdEE will load 4 or 0 for its argument, depending on the location of the above call statement. If called from MAIN.C, it loads the correct value of 4. However, it loads 0 when the statement is put in a function from another file MEM.C.

I solved the problem - see my reply below.

[ This message was edited by: Smiles on 22-12-2003 15:49 ]

[ This message was edited by: Smiles on 23-12-2003 08:11 ]

[ This message was edited by: Smiles on 23-12-2003 15:19 ]

scott239955
Associate II
Posted on May 17, 2011 at 11:35

The problem was that I was not including the I2C.H file in MEM.C. This is a simple mistake, but wish the compiler would flag an error showing that it does not have a function prototype:

unsigned char I2C_RdEE(unsigned char length);

Or, at least tell me that the assumed prototype does not match the function call. Is there a way to make this compiler do that? This seems like a basic thing for it to do and would save me a lot of grief?

[ This message was edited by: Smiles on 23-12-2003 15:30 ]

sjo
Associate II
Posted on May 17, 2011 at 11:35

Use the -W options, normally -Wall but -Wstrictprototypes will find functions without protoypes.

Regards

sjo
scott239955
Associate II
Posted on May 17, 2011 at 11:35

Thank you. Yes, that did the trick. Using the -Wall also produced alot of other useful warnings. There was only one that was a little annoying: if (x = my_function() ) produces a warning. I broke these sort of statements up because I could not turn of that particular warning:

x = my_function()

if (x)

In this example, it's not much different, but for something more complicated I wish I could turn off the warning:

if ( MyValue && ((x=my_funct) || (y=my_funct2)) )

I noticed it was easy to skip over a warning that was generated. Is it possible to have the output window generate a count of warnings at the end of the output?

Thanks