<?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>it takes two to tango but MISRA and Keil do not</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/35600/it-takes-two-to-tango-but-misra-and-keil-do-not</link><description> 
it takes two to tango but MISRA and Keil do not make good
partners. 

 
OK 
I have the following 
typedef signed char int8_t; 
typedef unsigned char uint8_t; 
the above to avoid depending on the compiler re (un)signed 
typedef char mchar_t; // auxilary</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: it takes two to tango but MISRA and Keil do not</title><link>https://community.arm.com/thread/121303?ContentTypeID=1</link><pubDate>Fri, 13 Apr 2018 10:29:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fea09796-bb9e-4427-9c2e-a5bca511100f</guid><dc:creator>&amp;#178;erik malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;It&amp;#39;s come to the point where I&amp;#39;ve actually forgotten the finer
details of printf() and scanf() format specifier....&lt;/i&gt;&lt;br /&gt;
so have I, but I dumped into this place where strcpy etc (fortunately
not printf) is sprinkled as heavy as spices on an indian dish.&lt;/p&gt;

&lt;p&gt;
we can argue till the cows come home re whether char chould be
equivalent to one of the two specifics, mchar_t takes care of it a
lot easier than 2743 lint exceptions. I still think it should work,
but the horse is dead so let&amp;#39;s not beat on it.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it takes two to tango but MISRA and Keil do not</title><link>https://community.arm.com/thread/109474?ContentTypeID=1</link><pubDate>Fri, 13 Apr 2018 08:32:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:54670d24-dfa9-4ddd-8864-fd842331a8a2</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;there should, as far as the compiler is concerned, be no
difference between &amp;#39;char&amp;#39; and &amp;#39;signed char&amp;#39;&lt;/i&gt;&lt;br /&gt;
That&amp;#39;s not actually correct. There really are &lt;b&gt;three&lt;/b&gt; types
named char: signed, unsigned and plain. The latter is required to be
very similar to one of the two others, but it&amp;#39;s &lt;b&gt;not&lt;/b&gt; the
same.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;Use of modifier or type &amp;#39;.....&amp;#39; outside of a typedef [MISRA
2012 Directive 4.6, advisory]&lt;/i&gt;&lt;br /&gt;
If you cast to char *: quite possibly. A cast to something like your
(mchar_t *) should work, though. You will get a pointer-to-pointer
cast, though.&lt;/p&gt;

&lt;p&gt;
I don&amp;#39;t think MISRA ever really expected anybody to use the
standard C library string functions. Remember it&amp;#39;s orginally an
automotive industry standard. There&amp;#39;s really not that much use for
printed characters in that field, much less for principally
unbounded, zero-terminated strings. I don&amp;#39;t think I&amp;#39;ve used strcpy()
at work more than twice in 10 years. It&amp;#39;s come to the point where
I&amp;#39;ve actually forgotten the finer details of printf() and scanf()
format specifier....&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;my ancient book stated that &amp;#39;char&amp;#39; is signed&lt;/i&gt;&lt;br /&gt;
Then it may not actually be sufficiently ancient, or not sufficiently
correct. ;-)&lt;/p&gt;

&lt;p&gt;
It was originally never specified whether plain char is signed or
not --- the distinction would have been largely irrelevant at the
time, because characters were, for all practical intents and
purposes, limited to ASCII, i.e. 7 bits. By the time of the first C
standard, enough implementations and code existed making either
assumption that neither stood a chance of making it into the official
version. That&amp;#39;s why we have the three types of char, instead.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it takes two to tango but MISRA and Keil do not</title><link>https://community.arm.com/thread/94386?ContentTypeID=1</link><pubDate>Fri, 13 Apr 2018 06:48:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a993a181-61c7-43f0-b670-524e6469521f</guid><dc:creator>&amp;#178;erik malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Nothing to do with either Keil or MISRA, actually.&lt;/i&gt;&lt;br /&gt;
oh? methinks Keil, if I check the &amp;quot;plain char is signed&amp;quot; box there
should, as far as the compiler is concerned, be no difference between
&amp;#39;char&amp;#39; and &amp;#39;signed char&amp;#39;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;At the very least, you have to apply a cast. And you may well
have to instrument that cast (e.t. with a /*lint ... */ comment) to
get it past a MISRA checker.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
which will result in:&lt;br /&gt;
Use of modifier or type &amp;#39;.....&amp;#39; outside of a typedef [MISRA 2012
Directive 4.6, advisory]&lt;/p&gt;

&lt;p&gt;
you can fill your code with /*lint ... */ comments but, e.g.
strcpy should accept (un)signed depending on the checkbox.&lt;/p&gt;

&lt;p&gt;
BTW was &amp;quot;plain char is signed&amp;quot; as a choce there in the original C,
my ancient book stated that &amp;#39;char&amp;#39; is signed&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it takes two to tango but MISRA and Keil do not</title><link>https://community.arm.com/thread/85658?ContentTypeID=1</link><pubDate>Thu, 12 Apr 2018 20:53:46 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:58ad4491-8466-4682-8901-857ffe3d4060</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
Nothing to do with either Keil or MISRA, actually.&lt;/p&gt;

&lt;p&gt;
Passing either signed or unsigned char to a function working on
plain char is wrong. At the very least, you have to apply a cast. And
you may well have to instrument that cast (e.t. with a /*lint ... */
comment) to get it past a MISRA checker.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>