Click here to Skip to main content
11,705,212 members (41,848 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
in the following struct:
struct
{
    bool simultaneousAction:1;
    bool action[7]:1;
};
i wonder why C2033 must be generated?! logically it must not be erroneous. there must be a byte first of which (LSb) be called simultaneousAction, the next bit be called action[0] and the last one (MSb) be called action[6].
what's the problem with this scenario and why do i get the following error?
error C2033: 'AsServoMotorProperties::<unnamed-tag>::action' : bit field cannot have indirection
Posted 13-Sep-12 2:51am
Comments
pasztorpisti at 13-Sep-12 8:55am
   
A C++ array can not be packed. Period.
Richard MacCutchan at 13-Sep-12 9:20am
   
Because you cannot directly address single bits, an array of bits is not a valid construct.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The underlying type of a bit field must be an integral type. An array is similar to a pointer and therefore not an integral type.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 550
1 OriginalGriff 244
2 ppolymorphe 126
3 CPallini 82
4 F-ES Sitecore 70
0 OriginalGriff 8,988
1 Sergey Alexandrovich Kryukov 8,272
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100