Click here to Skip to main content
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 921
1 OriginalGriff 250
2 Volynsky Alex 205
3 Kishore Pogaru 160
4 Richard Deeming 140
0 OriginalGriff 5,640
1 Sergey Alexandrovich Kryukov 4,693
2 CPallini 4,540
3 George Jonsson 3,132
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2014
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