AnsweredAssumed Answered

Porting problem: GNU to CW

Question asked by Wade Hassler on Jul 13, 2009
Latest reply on Jul 14, 2009 by bigmac

I am trying to move a project from GNU C to Codewarrior.

The first sticking point came up right away in the bit-fields:

 

| typedef union {
|    uint8 byte;
|    struct {
|        uint8 BIT7 : 1;  <- Warning: C1106 Non-Standard bitfield type
|        uint8 BIT5 : 1;  <- Warning: C1106 Non-Standard bitfield type
|        uint8 BIT4 : 1;  <- Warning: C1106 Non-Standard bitfield type
|        uint8 BIT2 : 1;  <- Warning: C1106 Non-Standard bitfield type
|        uint8 BIT1 : 1;  <- Warning: C1106 Non-Standard bitfield type
|        uint8 BIT0 : 1;  <- Warning: C1106 Non-Standard bitfield type
|    }bit;
|}reg08;

|typedef union {
|   uint16 word;
|    struct {
|        uint16 BIT15 : 1;
|        uint16 BIT14 : 1;
|        uint16 BIT13 : 1;
|        uint16 BIT12 : 1;
|        uint16 BIT11 : 1;
|        uint16 BIT10 : 1;
|        uint16 BIT9  : 1;
|        uint16 BIT8  : 1;
|        uint16 BIT7  : 1;
|        uint16 BIT6  : 1;
|        uint16 BIT5  : 1;
|        uint16 BIT4  : 1;
|        uint16 BIT3  : 1;
|        uint16 BIT2  : 1;
|        uint16 BIT1  : 1;
|        uint16 BIT0  : 1;
|    }bit;
}reg16;

|
|enum {  BIT15 = 0x8000,      <- Error C1014: Integral type expected or enum value  out of range

|        BIT14 = 0x4000,
|        BIT13 = 0x2000,
|        BIT12 = 0x1000,
|        BIT11 = 0x0800,
|        BIT10 = 0x0400,
|        BIT9  = 0x0200,
|        BIT8  = 0x0100 };

 

 .. that is, a warning each time 'uint8' is used in the enumeration, no warning when 'unit16' is used and an error when 'BIT15' is assigned a value over 32767, defined, as if it is actually a signed value

 

Changing the first eight to 'uint16' removes the first eight warnings, but the error has me stumped

 

Wade Hassler

Outcomes