473,804 Members | 3,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4203
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**********@h otmail.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
3430
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
10738
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 ASCII characters in the 0-127 range, although I had thought that I might want to use the 128-255 range for special symbols or foreign character codes. This all worked OK for a long time, but a recent update to the compiler on my system has...
4
5073
by: Patrick | last post by:
Anyone have any ideas on how to Marshal this parameter in C#? unsigned char* buf TIA, Patrick
2
7323
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 BF_set_key(BF_KEY *key, int len, const unsigned char *data); I've translated it as public static extern IntPtr BF_set_key (IntPtr key, int len, byte data) and I try to call it this way:
8
1795
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 < (1 << 7)) { *result = input; ++result; }else { *result = ((input >6) | 0xc0); ++result;
10
3129
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 the value of "l" get demoted to an unsigned int during the assignment, or does it remain a long? (I am on a system where
0
10332
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10077
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.