Topic : Compiler Warning with Bits in Structure

Forum : Ride IDE

Original Post
Post Information Post
January 14, 2009 - 7:13am
Guest

Hi Fellow Programmers:

I am getting a compiler warning when I try assign a 1/0 value to a bit (in a structure) based upon a test for the MSB in the right hand side. I am using RIDE-7.14.0001 with RKit-ARM 1.13.0810.

Here is my sample code:

// test file

#define RX_BIT_OVERTEMP 7 // rx bit for over temperature

// from stm32f10x_type.h
typedef unsigned char u8;

// Head Flags Structure
typedef struct
{
u8 no_comm : 1; // no comm bit
u8 jam : 1; // jam bit
u8 hi_temp : 1; // hi temp bit
u8 act_break : 1; // act break bit
u8 comm_lost : 1; // comm lost bit
u8 wire_break : 1; // wire break bit
u8 spare : 2; // spare bits
}head_flags_s;

void test_function(void)
{
head_flags_s s_head_alarm_flags; // temporary variable
u8 head_alarm_flags; // temporary variable
u8 actuator_flags; // temporary variable

// set/clear hi-temp bit according to actuator flags bit 7 (gets a warning):
s_head_alarm_flags.hi_temp = actuator_flags & (1<

Replies
Post Information Post
+1
0
-1
January 14, 2009 - 5:14pm
Guest

Hi

Yes I have the same warning which is "overflow in implicit constant conversion".

Matloub

+1
0
-1
January 16, 2009 - 8:08pm
Guest

Matloub:

So, can this warning be fixed?

The warning is incorrect, as shown by the two lines of code which follow the warning. There is no overflow. It appears that the GNU compiler is making a mistake by generating this warning.

Thanks,
Garry.