<?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>Viewing struct data during debug</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/17602/viewing-struct-data-during-debug</link><description> Hi, 
 
I am a new user of Keil C compiler. 
During debug, I am trying to watch struct data members. But all of them show 0x0000. And they are not updated. With other variables it&amp;#39;s just working fine. 
 
Any suggestions? 
 
Thanks, 
Titu </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/129930?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2005 07:59:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c1b22c10-2f71-4d07-94d4-1a644b9cda2f</guid><dc:creator>Titu Khan</dc:creator><description>&lt;p&gt;thanks Andy and Geert.&lt;br /&gt;
&lt;br /&gt;
I have got my codes into work following your suggestions :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/137971?ContentTypeID=1</link><pubDate>Sun, 02 Jan 2005 02:28:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bf1e5a8d-71ae-46a4-8a0e-bb2dfe5709f7</guid><dc:creator>Geert Vancompernolle</dc:creator><description>&lt;p&gt;&lt;i&gt;Let&amp;#39;s get the terminology correct here:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;don&amp;#39;t use the word static when defining the item in your c-file but declare it as external in the header file belonging to that c file.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In other words:&lt;br /&gt;
&lt;br /&gt;
The definition needs to be in exactly one .c file - without the &amp;#39;static&amp;#39; keyword;&lt;br /&gt;
&lt;br /&gt;
The &amp;#39;extern&amp;#39; declaration should be in the header file.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
You&amp;#39;ve put it in an more correct context, Andy, which is absolutely OK.&lt;br /&gt;
But you understood what I was trying to explain, and that&amp;#39;s the most important for me! ;-)&lt;br /&gt;
&lt;br /&gt;
-- Geert&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/122638?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 16:20:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d99d1471-da1d-445f-85d6-5c5d34707699</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Is it possible to use &amp;#39;extern&amp;#39; for static structs in order to access them in other files?&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;No, it is not.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I just explained what the &amp;#39;static&amp;#39; keyword means, and so has Geert Vancompernolle; thus it should be obvious that &amp;#39;extern&amp;#39; is meaningless with any &amp;#39;static&amp;#39; item!&lt;br /&gt;
&lt;br /&gt;
See your &amp;#39;C&amp;#39; textbook for further details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/134492?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 16:16:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1bbb2e3d-de5e-40f1-a04f-f41f0491cb82</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;don&amp;#39;t use the word static when declaring the item in your c-file but instead declare it as external in the header file belonging to that c file.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Let&amp;#39;s get the terminology correct here:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;don&amp;#39;t use the word static when &lt;/i&gt;&lt;b&gt;defining&lt;/b&gt;&lt;i&gt; the item in your c-file but &lt;b&gt;declare&lt;/b&gt; it as external in the header file belonging to that c file.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
In other words:&lt;br /&gt;
&lt;br /&gt;
The &lt;i&gt;&lt;b&gt;definition&lt;/b&gt;&lt;/i&gt; needs to be in exactly one &lt;b&gt;.c&lt;/b&gt; file - without the &amp;#39;static&amp;#39; keyword;&lt;br /&gt;
&lt;br /&gt;
The &amp;#39;extern&amp;#39; &lt;b&gt;declaration&lt;/b&gt; should be in the header file.&lt;br /&gt;
&lt;br /&gt;
Remember:&lt;br /&gt;
&lt;br /&gt;
The &lt;i&gt;&lt;b&gt;definition&lt;/b&gt;&lt;/i&gt; is what actually creates the item - this is what causes memory to be allocated;&lt;br /&gt;
&lt;br /&gt;
The &lt;i&gt;&lt;b&gt;declaration&lt;/b&gt;&lt;/i&gt; merely provides information for other modules that need to access the item - it causes no memory allocation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/122634?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 14:58:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b186ad3e-dec8-4a4a-ad98-038779bced2a</guid><dc:creator>Geert Vancompernolle</dc:creator><description>&lt;p&gt;Of course, that won&amp;#39;t work.  When declaring something static, you limit the scope of it &lt;b&gt;to the file in which it is declared&lt;/b&gt; (if it&amp;#39;s a file scope variable).&lt;br /&gt;
&lt;br /&gt;
What you want, is to have access to this item from external files, hence your proposal to make it external.&lt;br /&gt;
&lt;br /&gt;
To be able to do that, just don&amp;#39;t use the word &lt;b&gt;static&lt;/b&gt; when declaring the item in your c-file but instead declare it as external in the &lt;b&gt;header&lt;/b&gt; file belonging to that c file.&lt;br /&gt;
&lt;br /&gt;
Use that header file in the other c-files where you want to have access to the item.&lt;br /&gt;
&lt;br /&gt;
-- Geert&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/111246?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 12:15:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9c1bc960-9425-46ab-8e8f-4369eff95f06</guid><dc:creator>Titu Khan</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;The &amp;#39;static&amp;#39; keyword limits the scope of an identifier to the file in which it is defined.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Hey, I think that&amp;#39;s the reason! thanks a lot.&lt;br /&gt;
Is it possible to use &amp;#39;extern&amp;#39; for static structs in order to access them in other files? (Somewhere in this forum, I found that that does not work!)&lt;br /&gt;
&lt;br /&gt;
your suggestions and encouragements are certainly very much helpful.&lt;br /&gt;
&lt;br /&gt;
greetings,&lt;br /&gt;
titu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/96842?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 11:32:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0463c23b-6999-49cf-adc5-e7831c3a991b</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;I declared and defined some structures in 3 header files&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Well, that would be wrong for a start.&lt;br /&gt;
&lt;br /&gt;
I hope you mean that you &lt;i&gt;&lt;b&gt;defined&lt;/b&gt;&lt;/i&gt; each structure in exactly on &amp;#39;C&amp;#39; file, and used &amp;#39;extern&amp;#39; &lt;i&gt;&lt;b&gt;declarations&lt;/b&gt;&lt;/i&gt; in the headers?&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;structs are declared as static.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;#39;static&amp;#39; keyword limits the scope of an identifier to the file in which it is defined.&lt;br /&gt;
Therefore, you probably have an independant instance of each structure in each of your &amp;#39;C&amp;#39; files! ie, when one instance is updated in one file, &lt;i&gt;&lt;b&gt;none&lt;/b&gt;&lt;/i&gt; of the other instances is affected in any other file!&lt;br /&gt;
You are probably watching one instance in one file while your code is updating another!&lt;br /&gt;
&lt;br /&gt;
I think you need to go back to your &amp;#39;C&amp;#39; textbook.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/96845?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 11:26:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a8c1e87a-6d0e-4a2a-ba75-b9ceff2876f1</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;I have skimmed through the GS51.PDF document.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
I said you need to &lt;i&gt;&lt;b&gt;read&lt;/b&gt;&lt;/i&gt; the uVision Getting Started Guide, &lt;b&gt;and work through the example projects in it&lt;/b&gt; - &lt;i&gt;ie&lt;/i&gt;, study it thoroughly.&lt;br /&gt;
&lt;br /&gt;
You will not gain a proper understanding of anything by just skimming! You are probably still shooting in the dark.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/72981?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 08:04:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:34eecec6-2978-481d-9cb6-21a3e39425d0</guid><dc:creator>Titu Khan</dc:creator><description>&lt;p&gt;thank you for your kind response.&lt;br /&gt;
I have skimmed through the GS51.PDF document.&lt;br /&gt;
Still failed to find out a proper solution.&lt;br /&gt;
&lt;br /&gt;
The problems in detail:&lt;br /&gt;
&lt;br /&gt;
I declared and defined some structures in 3 header files and included them in other C files. structs are declared as static. The struct members are initialized by an initialization function.&lt;br /&gt;
&lt;br /&gt;
(I tried with defining the structs in header files and declaring them in one of the C files and then using &amp;#39;extern&amp;#39; in other C files; but that does not work as well.)&lt;br /&gt;
&lt;br /&gt;
Now, I am trying to update those struct data from all the C files, in some cases using ISRs. The struct members are not updated while viewing in the watch window.&lt;br /&gt;
&lt;br /&gt;
As a solution, I tried with using only one header file and one C file those cover all the codes. This time, it updates the values for struct members.&lt;br /&gt;
&lt;br /&gt;
So, what was the problem with earlier version?&lt;br /&gt;
&lt;br /&gt;
Thanks a lot and happy new year.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Viewing struct data during debug</title><link>https://community.arm.com/thread/43381?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2005 04:21:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:33d7b1dc-9757-4b70-8071-d0380dea7830</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Maybe this is a bug in your code - are you sure that the structure members are actually being updated by your code?&lt;br /&gt;
&lt;br /&gt;
Have you tried stepping through a bit of code that ought to update (part of) the structure, and seeing what happens?&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;I am a new user of Keil C compiler.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Did you start by reading the uVision &lt;i&gt;Getting Started&lt;/i&gt; Guide, &lt;b&gt;and working through the example projects in it?&lt;/b&gt;&lt;br /&gt;
This would give you a proper introduction to the tools, how they work, and how to use them.&lt;br /&gt;
(The uVision &lt;i&gt;Getting Started&lt;/i&gt; Guide is available on the &amp;#39;Books&amp;#39; tab in the &amp;#39;Project&amp;#39; Window; The &amp;#39;Books&amp;#39; window is also available &lt;i&gt;via&lt;/i&gt; the &amp;#39;Help&amp;#39; menu; failing all that, search for &lt;b&gt;GS51.PDF&lt;/b&gt; in your Keil folder)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>