<?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>Question on volatile keyword</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/29608/question-on-volatile-keyword</link><description> 
I was wondering why I would receive this error when I add the
volatile keyword - I am new to embedded C but my understanding was
that it just told the complier not to optimize the variable? 

 
This code give me no errors 

 
void display_text(char</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/140498?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2013 02:02:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:883be8da-c4c2-40a3-a37c-c40e1c936a52</guid><dc:creator>Incensed Zeusti</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;lt;quote&amp;gt;So you waited all the way until &amp;quot;Always yo&amp;#39;re
freind,&amp;quot; before you decided to add some faked language
errors.&amp;lt;/quote&amp;gt;&lt;/p&gt;

&lt;p&gt;
Nope. Check his name.&lt;/p&gt;

&lt;p&gt;
Remember back to what I said before [to you] regarding this
style.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/136954?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2013 01:41:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:087ae495-e529-4506-84ed-8e58744b2e2a</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
So you waited all the way until &amp;quot;Always yo&amp;#39;re freind,&amp;quot; before you
decided to add some faked language errors.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/136949?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2013 01:35:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:db3a6fb4-3131-41b4-baf4-4f9ef7069185</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;Stupid is as stupid does&amp;quot;.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/128005?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2013 01:12:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9a64ade2-ec29-41ca-bdfe-1a7d7b4d3014</guid><dc:creator>Incensed Zeusti</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;lt;quote&amp;gt;From the link above: (etcetera
etcetera)&amp;lt;/quote&amp;gt;&lt;/p&gt;

&lt;p&gt;
Tapir,&lt;/p&gt;

&lt;p&gt;
You have provided a very good explanation and I am glad to say you
are correct.&lt;/p&gt;

&lt;p&gt;
It fills me with pride to see that you have learnt how to
interpret, understand and respond.&lt;/p&gt;

&lt;p&gt;
Well done. Five gold stars.&lt;/p&gt;

&lt;p&gt;
Always yo&amp;#39;re freind,&lt;/p&gt;

&lt;p&gt;
Teacher Zeusti (retired)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/119962?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2013 00:58:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:16b73b4e-db03-4ab4-817e-08017999eed5</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
From the link above:&lt;/p&gt;

&lt;p&gt;
&amp;quot;It&amp;#39;s because implicit conversions can add qualifiers to the
target of pointer types, but not remove them. So if you want your
function to be able to accept volatile and/or const qualified
pointers, you must declare it with both:&lt;/p&gt;

&lt;p&gt;
void foo(const volatile char * data);&amp;quot;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/106840?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2013 00:09:59 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cd3a03fd-c1e7-4436-8163-3b94873f0002</guid><dc:creator>J. Chrisoph</dc:creator><description>&lt;p&gt;&lt;p&gt;
Just to be sure, try also:&lt;/p&gt;

&lt;p&gt;
int * volatile ptr_main;&lt;/p&gt;

&lt;p&gt;
I would expect no error there too.&lt;/p&gt;

&lt;p&gt;
volatile int * volatile ptr_main;&lt;/p&gt;

&lt;p&gt;
should again create that error message.&lt;/p&gt;

&lt;p&gt;
Why? With pointers there are two things, the pointer itself and
the content the pointer is pointing to. Both can be volatile
independently.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/92237?ContentTypeID=1</link><pubDate>Tue, 05 Feb 2013 21:30:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2293a562-7ee2-4ae4-baae-2439aba9ed23</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Seems only apply to pointers.&lt;/p&gt;

&lt;p&gt;
This is fine.&lt;/p&gt;

&lt;pre&gt;
#include &amp;lt;stdio.h&amp;gt;

void func1(const int var)
{
    printf(&amp;quot;Var is %d\n&amp;quot;, var);
}

int main(void)
{
    volatile int var_main = 1234;
    func1(var_main);

    return 0;
}
&lt;/pre&gt;

&lt;p&gt;
This is not.&lt;/p&gt;

&lt;pre&gt;
#include &amp;lt;stdio.h&amp;gt;

void func1(const int * var)
{
    printf(&amp;quot;Var is %d\n&amp;quot;, *var);
}

int main(void)
{
    volatile int var_main = 1234;
    volatile int * ptr_main = &amp;amp;var_main;
    func1(ptr_main);

    return 0;
}

&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Question on volatile keyword</title><link>https://community.arm.com/thread/61633?ContentTypeID=1</link><pubDate>Tue, 05 Feb 2013 21:12:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1d7b2ddc-28b4-495d-95c2-f7b2b7100bab</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;

&lt;a href="http://stackoverflow.com/questions/3457677/argument-of-type-volatile-char-is-incompatible-with-parameter-of-type-const"&gt;stackoverflow.com/.../argument-of-type-volatile-char-is-incompatible-with-parameter-of-type-const&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Because it also limits that how compiler(?) accesses a
variable.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>