473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

bit fields that do not fit in a built-in type

Does the C++ standard define what should happen if the size of int in the following code cannot accommodate the bit field?

struct bit_fields
{
unsigned int digit:17; // int is 16 bits
};

Mar 16 '06 #1
1 1572
Angel Tsankov wrote:
Does the C++ standard define what should happen if the size of int in the
following code cannot accommodate the bit field?

struct bit_fields
{
unsigned int digit:17; // int is 16 bits
};


The excess bits force are used for padding:

[9.6/1] A member-declarator of the form

identifier_opt : constant-expression

specifies a bit-field; its length is set off from the bit-field name by a
colon. The bit-field attribute is not part of the type of the class member.
The constant-expression shall be an integral constant-expression with a
value greater than or equal to zero. The constant-expression may be larger
than the number of bits in the object representation (3.9) of the
bit-field?s type; in such cases the extra bits are used as padding bits and
do not participate in the value representation (3.9) of the bit-field.
[...]

Best

Kai-Uwe Bux
Mar 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JZ | last post by:
I use Webware and FormKit. I have a problem with dynamic added field to the form. The following code creates one input field and two submit buttons. I would like to add more (up to 4) input fields...
1
by: Alex Elbert | last post by:
Hi I have built dynamic HTMLTable. Now I want to attach it directly to the Email Body - it is already built, so why not to use a ready table. However, I cannot find the way of getting plain HTML...
1
by: William | last post by:
Looking for a pre built dotnet corporate or small business website template.
3
by: CSDunn | last post by:
Hello, I have 14 fields on a report that hold integer values. The field names use the following naming convention: T1Number, T2Number ....T14Number. I need to get a 'sub total' of all fields as...
4
by: MS | last post by:
Access 97 I'm trying to check a table and add fields if necessary using code to a BE MDB. At the moment I'm reconnecting to the BE using code based on code written by Peter Vukovic...
9
by: sean.scanlon | last post by:
can someone help understand how i can could access a struct field dymanically like: foo->fields ? when i try to compile this i get the following error: 'struct pwd' has no member named 'fields'...
3
by: teser3 | last post by:
I am creating an Access 2000 database with a Web Front end that will have around 150 questions with 148 questions having just one number input (which will either be a 1 or a 2 or a 3 or a 4 or a...
8
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables...
1
by: just1812 | last post by:
I'm trying to pick off fileds from a line to insert them into a database. The problem that I'm having is that there is no delemiters between columns or set amount of spaces. Some columns have blank...
2
tdw
by: tdw | last post by:
I have a form which, when originally created, was solely for the purpose of viewing an order, not editing it (there was a different form for that), so the Allow Edits property was set to "No". But...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.