[Qt-interest] Question about bitfields

lists4pghanghas lists4pghanghas at gmail.com
Fri Jul 16 19:00:18 CEST 2010


Sorry, I didn't consider that you may be getting data from some other 
machine or
application.


On Friday 16 July 2010 09:06 PM, Atlant Schmidt wrote:
> Folks:
>
>    
>> Within a single application on a single machine, byte-
>> ordering with bitfields (and other issues around how
>> structs are packed) is no problem.
>>      
>    Wait, I take that back. Even if you simply like "unions",
>    you'll be exposed to the vagaries of bitfields.
>
>                        Atlant
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Atlant Schmidt
> Sent: Friday, July 16, 2010 11:26 AM
> To: Dan White; pritam ghanghas
> Cc: Qt Mailing List
> Subject: Re: [Qt-interest] Question about bitfields
>
> All:
>
>    
>> You need to know which end to start from.  Especially if you
>> are getting a bucket of bits from another machine and you
>> cannot guarantee it has the same byte order as your machine.
>>      
>    Right.
>
>    Within a single application on a single machine, byte-
>    ordering with bitfields (and other issues around how
>    structs are packed) is no problem. But the moment you
>    move bitfield data to another machine (via a file or
>    or via a network), you may have byte-ordering problems.
>
>    Given that it's pretty loosely specified how structs
>    can be packed, you even need to be careful how things
>    are packed *ON THE SAME MACHINE* if you've used more
>    than one compiler or linker. It's entirely possible that
>    a given compiler might blow a bitfield out to use an
>    complete byte (or more!) for each individual bit if
>    the compiler thinks that's an optimum implementation
>    for your chosen speed/size trade-offs.
>
>                             Atlant
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Dan White
> Sent: Friday, July 16, 2010 11:13 AM
> To: pritam ghanghas
> Cc: Qt Mailing List
> Subject: Re: [Qt-interest] Question about bitfields
>
> You need to know which end to start from.  Especially if you are getting a bucket of bits from another machine and you cannot guarantee it has the same byte order as your machine.
>
> "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
> Bill Waterson (Calvin&  Hobbes)
>
> ----- Pritam Ghanghas<pritam_ghanghas at infosys.com>  wrote:
>    
>> Why would there be any Byte Ordering issue while using C/C++ bit fields?
>>
>>
>> On Fri, 2010-07-16 at 18:55 +0530, Dan White wrote:
>>      
>>> Wow ! Thanks for that. I had not considered that.
>>>
>>> Is there anything available that covers byte-order ?
>>>
>>> "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
>>> Bill Waterson (Calvin&  Hobbes)
>>>
>>> ----- Atlant Schmidt<aschmidt at dekaresearch.com>  wrote:
>>>        
>>>> Dan:
>>>>
>>>>          
>>>>> Are there any Qt classes that deal with bitfields ?
>>>>> Or do I have to do it in plain old vanilla C ?
>>>>>            
>>>>    (As a way of helping us better understand your question,)
>>>>    what "value added" are you looking for beyond what is
>>>>    provided in the basic C/C++ language?
>>>>
>>>>    For example, "byte-order independence"?
>>>>
>>>>                            Atlant
>>>>
>>>> -----Original Message-----
>>>> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Dan White
>>>> Sent: Friday, July 16, 2010 8:49 AM
>>>> To: Qt Mailing List
>>>> Subject: [Qt-interest] Question about bitfields
>>>>
>>>> Are there any Qt classes that deal with bitfields ?  Or do I have to do it in plain old vanilla C ?
>>>>
>>>> I searched documentation and mailing lists and did not find anything.
>>>>
>>>> "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
>>>> Bill Waterson (Calvin&  Hobbes)
>>>>
>>>> _______________________________________________
>>>> Qt-interest mailing list
>>>> Qt-interest at trolltech.com
>>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>>
>>>> This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
>>>>
>>>> Thank you.
>>>>
>>>> Please consider the environment before printing this email.
>>>>          
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>        
>>
>> **************** CAUTION - Disclaimer *****************
>> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
>> for the use of the addressee(s). If you are not the intended recipient, please
>> notify the sender by e-mail and delete the original message. Further, you are not
>> to copy, disclose, or distribute this e-mail or its contents to any other person and
>> any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
>> every reasonable precaution to minimize this risk, but is not liable for any damage
>> you may sustain as a result of any virus in this e-mail. You should carry out your
>> own virus checks before opening the e-mail or attachment. Infosys reserves the
>> right to monitor and review the content of all messages sent to or from this e-mail
>> address. Messages sent to or from this e-mail address may be stored on the
>> Infosys e-mail system.
>> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>      
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
>
> Thank you.
>
> Please consider the environment before printing this email.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
>
> Thank you.
>
> Please consider the environment before printing this email.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>    




More information about the Qt-interest-old mailing list