Topic : RIDE mischaracterizes type bool arrays; workaround available

Forum : ARM

Original Post
Post Information Post
October 31, 2007 - 1:00am
Guest

C:\RIDE\LIB\STRX\STR75X_LIB\INCLUDE\75x_type.h defines bool as

typedef enum { FALSE = 0, TRUE = !FALSE } bool;

C defines enum as type int, which is 4 bytes in the GNUARM implementation.

I have declared an array

bool A2D_12BitChannelsInUse[11];

GNUARM allocates 44 bytes to this array. However, the RIDE debugger shows this as a byte array. Thus if the following occurs after the array is initialized to 0:

A2D_12BitChannelsInUse[1] = 1;

RIDE will then display it ("formatted" as an 11-element array) as follows:

+ A2D_12BitChannelsInUse {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}

Then if the following occurs:

A2D_12BitChannelsInUse[2] = 1;

RIDE will then display it as follows:

+ A2D_12BitChannelsInUse {0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0}

This is wrong. To be correct, these two examples should show

+ A2D_12BitChannelsInUse {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}

and

+ A2D_12BitChannelsInUse {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0}

Expanding the array also shows this erroneous representation, e.g.

- A2D_12BitChannelsInUse {0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0}
- A2D_12BitChannelsInUse[0] 0
- A2D_12BitChannelsInUse[1] 0
- A2D_12BitChannelsInUse[2] 0
- A2D_12BitChannelsInUse[3] 0
- A2D_12BitChannelsInUse[4] 1
- A2D_12BitChannelsInUse[5] 0
- A2D_12BitChannelsInUse[6] 0
- A2D_12BitChannelsInUse[7] 0
- A2D_12BitChannelsInUse[8] 1
- A2D_12BitChannelsInUse[9] 0
- A2D_12BitChannelsInUse[10] 0

A workaround is to declare the array as u8 instead of bool.