<?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>unnamed variable as place holder inside struct</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/42557/unnamed-variable-as-place-holder-inside-struct</link><description> Does any one know how to create an unnamed variable for place holder in a struct? I know you can do it in bitfiled. 
 
Example: 
 
 
struct S
{
 int a;
 int b;
 int[5]; //reserved 5 ints but dont&amp;#39; need to name it.
 int c;
 int d;

 int bit0 : 1;
 int</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/134535?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2005 12:32:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d4312f55-be0d-444f-a3bd-ece8d1207e95</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;I had a lots of reserved fields for backward compatiblity with existing software.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
In that case, I&amp;#39;d say it&amp;#39;s particularly important that you &lt;i&gt;&lt;b&gt;do&lt;/b&gt;&lt;/i&gt; give them specific names that clearly indicate what&amp;#39;s going on!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/122730?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2005 12:09:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5f16fb4d-8e83-4074-9387-8394158a16b5</guid><dc:creator>Anh Phan</dc:creator><description>&lt;p&gt;Thanks everyone for their help.  I had a lots of reserved fields for backward compatiblity with existing software.&lt;br /&gt;
&lt;br /&gt;
Anh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/122716?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2005 08:16:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:65a8e592-e3f0-4064-8362-ff11023cd5a0</guid><dc:creator>Karl Hamsher</dc:creator><description>&lt;p&gt;If your objective is simply to avoid the drudgery of typing &amp;#39;reserved&amp;#39; structure member names, this short AWK script will do it for you:&lt;br /&gt;
&lt;pre&gt;BEGIN { FS = &amp;quot;[&amp;quot; }

/[ \t]+(char|short|int|long)\[/ {
	count_str = sprintf(&amp;quot;%03d&amp;quot;, count++)
	$0 = $1 &amp;quot; reserved_&amp;quot; count_str &amp;quot;[&amp;quot; $2
}

{print}&lt;/pre&gt;
Such that:&lt;br /&gt;
&lt;pre&gt;struct S
{
   int a;
   int b;
   int[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   char[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   long[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   int[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   int c;
   int d;

   int  bit0 : 1;
   int       : 6;
   int  bit7 : 1;
}&lt;/pre&gt;
becomes&lt;br /&gt;
&lt;pre&gt;struct S
{
   int a;
   int b;
   int reserved_000[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   char reserved_001[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   long reserved_002[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   int reserved_003[5]; //reserved 5 ints but dont&amp;#39; need to name it.
   int c;
   int d;

   int  bit0 : 1;
   int       : 6;
   int  bit7 : 1;
}&lt;/pre&gt;
A native Win32 AWK is available at &lt;a href="http://unxutils.sourceforge.net/" target="_blank"&gt;http://unxutils.sourceforge.net/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/111355?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2005 17:13:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8ad38cb8-9546-44db-bf6c-7ca5a5e27341</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;Take a look at &lt;a href="http://www.keil.com/forum/docs/thread2150.asp"&gt;http://www.keil.com/forum/docs/thread2150.asp&lt;/a&gt; and modify it for this situation.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/97026?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2005 13:46:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bb58cb98-436c-485e-95d9-6ed93ee3453b</guid><dc:creator>Anh Phan</dc:creator><description>&lt;p&gt;Thanks Jon,  I like your method.  Any suggestions for arrays?&lt;br /&gt;
&lt;br /&gt;
Anh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/87140?ContentTypeID=1</link><pubDate>Sun, 20 Mar 2005 08:35:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e1196ca6-9eda-4a24-9259-80e9b20b9256</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;i&gt;Would this work?&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Not really --- keeping in mind that this method relies on the magic number 8 having its usual meaning of &amp;quot;number of bits in a byte&amp;quot;, and that I don&amp;#39;t think anonymous bitfields are supposed to have a width assigned to them --- they&amp;#39;re supposed to be used to &amp;quot;flush&amp;quot; one machine word, so the next bitfield will start in a word of its own.  Neither am I convinced they&amp;#39;re guaranteed to start a new one if the next bit would have been in a fresh word already.&lt;br /&gt;
&lt;br /&gt;
To summarize: the problem is in what the OP is trying to do, not in Keil preventing him from doing it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/43728?ContentTypeID=1</link><pubDate>Sat, 19 Mar 2005 20:34:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:428e2029-df0c-40c1-804a-a2af2e813951</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;Would this work?&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
struct S
{
   int a;
   int b;
   char :8;
   char :8;
   char :8;
   char :8;
   char :8;
   char :8;
   char :8;
   char :8;
   char :8;
   char :8;
   int c;
   int d;
   int  bit0 : 1;
   int       : 6;
   int  bit7 : 1;
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/97009?ContentTypeID=1</link><pubDate>Sat, 19 Mar 2005 15:24:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c8642fae-6aff-405a-918e-b50af22307b7</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;The problem is that I have way too many non-contiguous &amp;#39;reserved&amp;#39; field.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Why??&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Does this not suggest something that needs to be fixed in your design?&lt;br /&gt;
&lt;br /&gt;
As you say yourself that there&amp;#39;s &amp;quot;way too many,&amp;quot; why don&amp;#39;t you get rid of &amp;#39;em?!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/43729?ContentTypeID=1</link><pubDate>Sat, 19 Mar 2005 08:14:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:af435c47-2423-44b0-a4c6-0b1d3ad4aa68</guid><dc:creator>Mik Kleshov</dc:creator><description>&lt;p&gt;As far as I know, the C standard does not define anonymous non-bitfield struct members. Since Keil&amp;#39;s C compilers claim to be ANSI C compliant, you can&amp;#39;t expect them to have this feature. It seems that you&amp;#39;ll have to do with named struct members.&lt;br /&gt;
&lt;br /&gt;
- mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/111354?ContentTypeID=1</link><pubDate>Sat, 19 Mar 2005 03:38:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f48c7563-6495-4f04-8507-dee916af2b69</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Implicit in my previous post was the suggestion that you use a standard format; eg, call them all &lt;b&gt;reserved_&lt;i&gt;xxx&lt;/i&gt;&lt;/b&gt;, where &lt;i&gt;xxx&lt;/i&gt; is just a 3-digit (or whatever) number.&lt;br /&gt;
&lt;br /&gt;
Using a fixed 3 (or whatever) digits means that a simple text sort (eg, as in the uVision browser) will put them in the right order - otherwise you get reserved_9 coming before reserved_199 in a sorted list!&lt;br /&gt;
&lt;br /&gt;
Also, a fixed size makes it easier to construct a regular expression to find them all&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/97007?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2005 17:40:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:379a0feb-c0f3-401e-ac29-5a8cd2358cf3</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;I think giving it a name is probably a better idea:&lt;br /&gt;
&lt;br /&gt;
At least then you can set a breakpoint on &amp;quot;reserved_027&amp;quot; to ensure that nothing is (unwittingly) accessing it.&lt;br /&gt;
&lt;br /&gt;
And you can easily do a text search for &amp;quot;reserved_&amp;quot; to find them all.&lt;br /&gt;
&lt;br /&gt;
And, in the future version that starts using one of them, your can say &amp;quot;reserved_459 is now used for hyperdrive_warp_factor&amp;quot; or whatever.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/73114?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2005 16:55:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ef256654-e097-4532-89b8-054629d934ce</guid><dc:creator>Anh Phan</dc:creator><description>&lt;p&gt;The problem is that I have way too many non-contiguous &amp;quot;reserved&amp;quot; field.  Is there a way to leave it unnamed?&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
&lt;br /&gt;
Anh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unnamed variable as place holder inside struct</title><link>https://community.arm.com/thread/43730?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2005 16:36:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3d943cdd-8cdc-41e9-ba73-aaa3aab01fa6</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;call it Ralph and all will work.  If Ralph is already used, call it Phred.  My usual name for such is &amp;quot;expansion_space&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>