Topic : Global variable problem

Forum : ST7/STM8

Original Post
Post Information Post
March 26, 2010 - 2:43pm
Guest

I have a global variable

u8 hours_dig_five;

I have a function that increments the variable:

17 1 ++hours_dig_five;

which then compiles to

; SOURCE LINE # 17
0004 CE0000 F LDW X,hours_dig_five
0007 5C INCW X
0008 CF0000 F LDW hours_dig_five,X

It looks to me like the global is being treated as an int, but I have it declared as a char. Is there a compiler or preprocessor setting that will prevent this from happening?

Thanks for any help,

Eric

Replies
Post Information Post
+1
0
-1
March 29, 2010 - 9:02am
Raisonance Support Team

Hi Eric,

Definitely no, a char is always an 8-bit object. What you can change is whether it has a signed or an unsigned qualifier by default.
There must be some problem with your "u8" definition. Can you add the following as the first line of your C file:
#pragma preprint

This will generate a preprocessed source file, with extension ".i".
When you analyze this preprocessed file you should have a clearer view of what's happening, so the fix should be easier.

In case you are not able to find the problem, can you share your preprocessed ".i" file as well as your listing file ".lst" with us, so that we can help further?

Regards,
Bruno