473,396 Members | 1,797 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.

don't understand declaration "unsigned int ip_v:4"

Hi,

I am looking at netinet/ip.h in linux code, and the declaration:
unsigned int ip_hl:4 make me confused.

I can understand "unsigned int ip_hl", but, what does ":4" here mean?

Very grateful to any answer.

Jian
Nov 13 '05 #1
2 4169
In article <16**************************@posting.google.com >, jian wrote:
I am looking at netinet/ip.h in linux code, and the declaration:
unsigned int ip_hl:4 make me confused.


It's probably a bit field in a struct.

--
Andreas Kähäri
Nov 13 '05 #2
On 2003-10-24, jian <ch**********@hotmail.com> wrote:
I am looking at netinet/ip.h in linux code, and the declaration:
unsigned int ip_hl:4 make me confused.

I can understand "unsigned int ip_hl", but, what does ":4" here mean?


This kind of syntax is only allowed for a union or struct field, and
declares a bit-field. In this case, it is declaring ip_hl to hold
values that fit in 4 bits.

-- James
Nov 13 '05 #3

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

Similar topics

43
by: M-One | last post by:
See subject: how do I calloc (and free the memory, if that's not free(my_bytes);) this? TIA!
4
by: John Devereux | last post by:
Hi, I would like some advice on whether I should be using plain "chars" for strings. I have instead been using "unsigned char" in my code (for embedded systems). In general the strings contain...
4
by: Patrick | last post by:
Anyone have any ideas on how to Marshal this parameter in C#? unsigned char* buf TIA, Patrick
2
by: runner | last post by:
I'm trying to call some functions from OpenSSL library but I'm a bit confused when I have to use pinvoke. first function should create key from some input data, it's declared : void...
8
by: FabioAng | last post by:
Assuming I have this function (it's not complete): template<typename InputType, typename OutputIterator> void to_utf8(InputType input, OutputIterator result) { // trivial conversion if (input...
10
by: Kenneth Brody | last post by:
Does the cast "(unsigned)" imply "(unsigned int)", or does it simply strip the signedness from the variable? In other words, given this: long l = -123; unsigned long ul = (unsigned)l; Does...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.