<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Struct problems</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31772/struct-problems</link><description> 
First off, I am fairly new to chip level programming! 

 
I am using a SILabs C8051F330 and I am having trouble in the
compilation 
of some libraries that I need to use that were given by Texas
Instruments to 
implement a SPI interface to one of their</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Struct problems</title><link>https://community.arm.com/thread/107057?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2013 08:40:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6f74022b-cb20-46ba-96f1-94cf23d7f27c</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Based on the error message, I&amp;#39;m making the conclusion that Keil
C51 only supports (unsigned) char and int as data types for bit
fields.&lt;/p&gt;

&lt;p&gt;
At the same time, I know that an int in C51 is 16-bit, in which
case I have to assume that a uint32_t is a unsigned long int - a data
type the error message claims isn&amp;#39;t supported.&lt;/p&gt;

&lt;p&gt;
I can very well understand why C51 don&amp;#39;t want to support it - the
processor is 8-bit, so it requires library helper functions or lots
of inlined assembler instructions to work with 32-bit integers. And
it doesn&amp;#39;t get easier with 32-bit bit fields, since the individual
bit fields need not be aligned on bytes. Live is so trivial when the
compiler can implement the bit manipulation natively, by operating on
a single full-size register. Just think about taking a value larger
than what fits in any register, and then shift it more steps than
what fits in any register, before storing the value in a variable
that is 4 times the size of a basic processor register. Obviously
possible, but costing a lot in a tiny processor with normally limited
code space.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Struct problems</title><link>https://community.arm.com/thread/120038?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2013 07:03:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f662ca6e-bcec-4716-b610-5651b5d85003</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Note that IAR make compilers for a huge range of chips - maybe
they were referring to an IAR compiler where &lt;b&gt;int&lt;/b&gt; is 32
bits?&lt;/p&gt;

&lt;p&gt;
The &amp;#39;C&amp;#39; language standard specifies only &amp;#39;int&amp;#39;, &amp;#39;unsigned int&amp;#39; or
&amp;#39;signed int&amp;#39; as the base for fields - so Keil C51 is giving an
&lt;i&gt;&lt;b&gt;extension&lt;/b&gt;&lt;/i&gt; by allowing &amp;#39;char&amp;#39;&lt;/p&gt;

&lt;p&gt;
Maybe this &amp;quot;IAR&amp;quot; compiler allow 32-bit fields as an
&lt;i&gt;&lt;b&gt;extension&lt;/b&gt;&lt;/i&gt;...?&lt;/p&gt;

&lt;p&gt;
In the words of K&amp;amp;R:&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;Almost everything about fields is
implementation-dependent&amp;quot;&lt;/i&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Struct problems</title><link>https://community.arm.com/thread/117276?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2013 07:02:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ba56435e-c2a3-4d64-83c4-adb1951d43b6</guid><dc:creator>chris mcdaniel</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for the information. The stdint definition for uint32_t is
unsigned long int.&lt;br /&gt;
So that&amp;#39;s got to be the issue.&lt;/p&gt;

&lt;p&gt;
Thanks&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Struct problems</title><link>https://community.arm.com/thread/81185?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2013 06:39:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:104b0815-8cca-4211-8d30-8e0e0c449706</guid><dc:creator>chris mcdaniel</dc:creator><description>&lt;p&gt;&lt;p&gt;
So are you asking me or telling me that KEIL C51 compiler does NOT
handle these type of structures?&lt;/p&gt;

&lt;p&gt;
According to TI, the library was originally written using IAR
compiler. I was using KEIL because of other projects we had already
compiled using it.&lt;/p&gt;

&lt;p&gt;
Again, thanks for your help!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Struct problems</title><link>https://community.arm.com/thread/68249?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2013 06:32:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:edcc4aee-e650-44ab-b40c-7ab1c669c691</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
If the Keil C51 compiler can&amp;#39;t handle (unsigned) long as data type
for bit fields, then you haven&amp;#39;t much options but to rewrite the code
so you manually shift in the two field values into a single uint32_t
variable and use that one instead.&lt;/p&gt;

&lt;p&gt;
But the interesting thing: If C51 doesn&amp;#39;t support uint32_t bit
fields - what compile was that library written for?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>