|
-
February 13th, 2007, 03:36 PM
#16
Re: How to get certain bits from a value?
 Originally Posted by Mitsukai
i dont think u understand my statement..as logn as bit fields are not to be portable they are almost useless..
Yes, it's true that bitfields aren't very useful.
For example, writing raw structures containing bitfields to files produce non-portable file formats. It's true to some extent for any binary data type (text formats rule )... But, for integer types, you can write a format portable to all 32 bits little-endian machines and with a bit of coding, these file formats can even be read on big endian and middle endian machines.
Bit fields are far from being panacea. They're seldomly useful.
But, sometimes, they can be handy and are in the language mainly because they've been in it for a long time.
Nevertheless, ABI exist (I'm not sure there exists a reliable ABI under Win32 which seems a quite bad system for binary compatibility... especially for C++) on some systems. For example, there's a System V i386 ABI which specifies how bit fields, structures and unions are layout in memory.
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|