Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #41211

Re: Union of bitfields and larger type on ARM

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++, comp.dsp, sci.electronics.design
Subject Re: Union of bitfields and larger type on ARM
Date Wed, 24 Feb 2016 14:48:49 +1300
Lines 48
Message-ID <dj4gg1Fj7j3U7@mid.individual.net> (permalink)
References <If2zy.23937$Nf2.15642@fx14.iad> <MPG.3136d3f791b98659989e8b@news.eternal-september.org>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net Ebg1gp/a+3XdjV3TlGtxigRaYOx7oPAPBmQOMlQN88AzaSyfbh
Cancel-Lock sha1:WLWbOe3wVWCNbYIAmq0xIqv9Iw4=
User-Agent Mozilla/5.0 (X11; SunOS i86pc; rv:17.0) Gecko/17.0 Thunderbird/17.0
In-Reply-To <MPG.3136d3f791b98659989e8b@news.eternal-september.org>
Xref csiph.com comp.lang.c++:41211 comp.dsp:30530 sci.electronics.design:400155

Cross-posted to 3 groups.

Show key headers only | View raw


M Philbrook wrote:
> In article <If2zy.23937$Nf2.15642@fx14.iad>,
> bitrex@de.lete.earthlink.net says...
>>
>> Does anyone know if the following "naughty" (implementation dependent)
>> construct would work "correctly" on the ARM Cortex M4, compiled with
>> arm-gcc-embedded?
>>
>> typedef union {
>>         uint32_t phase_accumulator_full;
>>         struct {
>>           uint8_t integer_high : 8,
>>                   integer_low : 8,
>>                   frac_high  : 8,
>>                   frac_low  : 8;
>>
>>         };
>> } phase_accumulator;
>
> sumg ting does not look correct? Assuming I understand what you're
> after.
>
> struct _phase_acc {
>
> 	union { uint32_t phase_accumulator_full };

typo..

> 	union { uint_8 integer_high:8,

typo..
> 			 integer_low:8,
> 			 frac_high:8,
> 			 frc_low : 8;
>   		};
>      } phase_accumulator;
>
> You can include a condition to test for the second union to
> determine the endious of the platform to correctly compile
> the code for the bit field order.
>
>   The above struct should overlay to generate a single 32 bit image.

No, it won't.  You have two 32 bit unions members of a struct, witch 
gives a 64 bit struct.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Union of bitfields and larger type on ARM bitrex <bitrex@de.lete.earthlink.net> - 2016-02-23 14:17 -0500
  Re: Union of bitfields and larger type on ARM John Devereux <john@devereux.me.uk> - 2016-02-23 19:36 +0000
    Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-23 22:34 +0100
      Re: Union of bitfields and larger type on ARM bitrex <bitrex@de.lete.earthlink.net> - 2016-02-23 16:45 -0500
        Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-23 23:21 +0100
      Re: Union of bitfields and larger type on ARM spope33@speedymail.org (Steve Pope) - 2016-02-25 00:06 +0000
        Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-25 01:29 +0100
  Re: Union of bitfields and larger type on ARM Tim Wescott <seemywebsite@myfooter.really> - 2016-02-23 15:53 -0600
    Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-23 23:48 +0100
      Re: Union of bitfields and larger type on ARM Christian Gollwitzer <auriocus@gmx.de> - 2016-02-24 09:44 +0100
        Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-24 10:39 +0100
    Re: Union of bitfields and larger type on ARM Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2016-02-24 09:54 +0200
  Re: Union of bitfields and larger type on ARM M Philbrook <jamie_ka1lpa@charter.net> - 2016-02-23 20:39 -0500
    Re: Union of bitfields and larger type on ARM Ian Collins <ian-news@hotmail.com> - 2016-02-24 14:48 +1300
  Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-24 10:41 +0100
  Re: Union of bitfields and larger type on ARM Les Cargill <lcargill99@comcast.com> - 2016-02-25 12:05 -0600
    Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-26 17:09 +0100
      Re: Union of bitfields and larger type on ARM scott@slp53.sl.home (Scott Lurndal) - 2016-02-26 17:29 +0000
        Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-26 18:42 +0100
      Re: Union of bitfields and larger type on ARM Les Cargill <lcargill99@comcast.com> - 2016-02-26 19:07 -0600
      Re: Union of bitfields and larger type on ARM Allan Herriman <allanherriman@hotmail.com> - 2016-02-27 08:58 +0000
        Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-27 14:37 +0100
          Re: Union of bitfields and larger type on ARM Öö Tiib <ootiib@hot.ee> - 2016-02-27 07:21 -0800
            Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-27 16:34 +0100
              Re: Union of bitfields and larger type on ARM Öö Tiib <ootiib@hot.ee> - 2016-02-27 10:14 -0800
                Re: Union of bitfields and larger type on ARM David Brown <david.brown@hesbynett.no> - 2016-02-28 15:26 +0100
              Re: Union of bitfields and larger type on ARM Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-27 16:40 -0500
                Re: Union of bitfields and larger type on ARM Paavo Helde <myfirstname@osa.pri.ee> - 2016-02-28 00:47 +0200
                Re: Union of bitfields and larger type on ARM Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-27 18:21 -0500
                Re: Union of bitfields and larger type on ARM Paavo Helde <myfirstname@osa.pri.ee> - 2016-02-28 01:33 +0200
                Re: Union of bitfields and larger type on ARM Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-27 20:15 -0500

csiph-web