Home > other >  Questions about c language in operation
Questions about c language in operation

Time:01-17

How in the midst of a byte, set up a few of them a read-only bit? Such as uint8_t a; Only need it a bit read-only, the rest can be a normal, speaking, reading and writing, and how to solve this?

CodePudding user response:

Never done
Don't know C does not support team

 typedef struct 
{
Uint32 m1:1;
Const uint32 m2:1;
.
} S1.

CodePudding user response:

The demand of the exotic,

You can use a mask and logical operations, ensure that won't be change

CodePudding user response:

2 floor method is feasible, if it is 51 single-chip microcomputer and structure, can be directly 8 bits variables,
The original poster is probably what to analog device, the device some registers are read-only,
  • Related