whats wrong with this typedef union ( boostC Compiler )

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

whats wrong with this typedef union ( boostC Compiler )

Post by Rudi »

hi,

i try isolated usb project and not sure why get a compiler error with this
typedef union c code as supplementary:
i use PIC18F2550 - boostC Compiler

i change BYTE in unsigned char in this example.

if i start with an empty PIC18F2550 project
and added this c code in supplementary for using
i get compiler error with 'missing brace'
..

Code: Select all

typedef union
{
    unsigned char    bitmap;
    struct
    {
        unsigned char ep_num:    4;
        unsigned char zero_pkt:  1;
        unsigned char dts:       1;
        unsigned char force_dts: 1;
        unsigned char direction: 1;
    }field;
} TRANSFER_FLAGS;
thanks for help

best wishes
rudi ;-)

Code: Select all

CODETEST.c(145): error: general error
CODETEST.c(145): error: missing right brace
CODETEST.c(145): error: general error
CODETEST.c(145): error: missing right brace
CODETEST.c(145): error: identifier expected
CODETEST.c(145): error: missing right brace
CODETEST.c(145): error: general error
CODETEST.c(145): error: missing right brace
CODETEST.c(145): error: general error
CODETEST.c(145): error: missing right brace
CODETEST.c(145): error: identifier expected
CODETEST.c(145): error: missing right brace

c code:

Code: Select all


133:   /*=----------------------------------------------------------------------=*\
134:      Use :Supplementary defines
135:   \*=----------------------------------------------------------------------=*/
136:   // #ifndef BYTE
137:   //  typedef unsigned char BYTE ;
138:   // #endif
139:
140:   typedef union
141:   {
142:      unsigned char  bitmap;
143:       struct
144:       {
145:           unsigned char ep_num:    4;
146:           unsigned char zero_pkt:  1;
147:           unsigned char dts:       1;
148:           unsigned char force_dts: 1;
149:           unsigned char direction: 1;
150:       }field;
151:   } TRANSFER_FLAGS;


Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: whats wrong with this typedef union ( boostC Compiler )

Post by Rudi »

think at code is nothing wrong,
think its the boostC compiler, that do not support Bit Fields.
thanks for help.
best wishes
rudi ;-)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: whats wrong with this typedef union ( boostC Compiler )

Post by Benj »

Hi Rudi,

One for the Sourceboost forums I believe. :D

BoostC is not a standard GCC based compiler and by modern standards is a bit of a relic. One of the reasons we are moving to a new compiler for the next Flowcode release. We just have to be careful we don't break things that currently work.

Post Reply