<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>CodeWarrior for MCU中的主题 Re: #error directive format</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130064#M985</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Doug,&lt;BR /&gt;the reason why the compiler does not accept&lt;BR /&gt;&amp;nbsp;#errror this 'test'&lt;BR /&gt;is because it treats everything after the #error as 'preprocessing' tokens.&lt;BR /&gt;If you double quote things after the #error, then it is a 'string' and you can have in it whatever is legal for a typical string in the C language.&lt;BR /&gt;If you do not double quote it, it get's a little bit tricky as your example contains single quotes. Typically, with single quotes you specify character constants like 'a'.&lt;BR /&gt;Now in your case the compiler rejects it because he does not accept a character constant with more than one character in it.&lt;BR /&gt;Checking the standard (ANSI/ISO 9899-1990) on this, in fact the standard would allow multi-character constants like 'test', but it says:&lt;BR /&gt;"The value of an integer character constant containing more than one character, or ....., is implementation defined."&lt;BR /&gt;So from this perspective, I would say that the compiler is consistent with the standard, but I would expect that the compiler would accept a character constant with more than one character in it (actually it accepts escape sequences and trigraphs in it).&lt;BR /&gt;But you still would run into problems if you would just use a single quote like&lt;BR /&gt;#error don't do this&lt;BR /&gt;&lt;BR /&gt;I recommend that it would be the easiest thing for you if you double quote the message for the #error directive.&lt;BR /&gt;&lt;BR /&gt;Erich&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Apr 2007 14:50:49 GMT</pubDate>
    <dc:creator>BlackNight</dc:creator>
    <dc:date>2007-04-10T14:50:49Z</dc:date>
    <item>
      <title>#error directive format</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130063#M984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I am using the CWHCS12 toolset and am trying to compile some C-code that contains variaous #error directives.&amp;nbsp; The #error directives contain some phases enclosed by single quote characters.&amp;nbsp; When compiling this code I get errror C4422 from the compiler.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;By trial and error I have narrowed it down to the formats of #error directive text strings that work and don't work.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;// Strings accepted by the compiler include...&lt;BR /&gt;&lt;BR /&gt;#if 0&lt;BR /&gt;#error "This 'test' works."&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;#if 0&lt;BR /&gt;#error This test works.&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// Strings that don't work include...&lt;BR /&gt;&lt;BR /&gt;#if 0&lt;BR /&gt;#error This 'test' doesn't work, it gives error C4422.&lt;BR /&gt;#endif&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Does anyone know what the ANSI-C standard says the format of the text strings supported by the #error directive should be?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Is the behavior I described above consistent with this standard?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks,&lt;/DIV&gt;&lt;DIV&gt;--Doug&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2007 03:48:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130063#M984</guid>
      <dc:creator>Doug_O</dc:creator>
      <dc:date>2007-04-10T03:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: #error directive format</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130064#M985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Doug,&lt;BR /&gt;the reason why the compiler does not accept&lt;BR /&gt;&amp;nbsp;#errror this 'test'&lt;BR /&gt;is because it treats everything after the #error as 'preprocessing' tokens.&lt;BR /&gt;If you double quote things after the #error, then it is a 'string' and you can have in it whatever is legal for a typical string in the C language.&lt;BR /&gt;If you do not double quote it, it get's a little bit tricky as your example contains single quotes. Typically, with single quotes you specify character constants like 'a'.&lt;BR /&gt;Now in your case the compiler rejects it because he does not accept a character constant with more than one character in it.&lt;BR /&gt;Checking the standard (ANSI/ISO 9899-1990) on this, in fact the standard would allow multi-character constants like 'test', but it says:&lt;BR /&gt;"The value of an integer character constant containing more than one character, or ....., is implementation defined."&lt;BR /&gt;So from this perspective, I would say that the compiler is consistent with the standard, but I would expect that the compiler would accept a character constant with more than one character in it (actually it accepts escape sequences and trigraphs in it).&lt;BR /&gt;But you still would run into problems if you would just use a single quote like&lt;BR /&gt;#error don't do this&lt;BR /&gt;&lt;BR /&gt;I recommend that it would be the easiest thing for you if you double quote the message for the #error directive.&lt;BR /&gt;&lt;BR /&gt;Erich&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2007 14:50:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130064#M985</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2007-04-10T14:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: #error directive format</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130065#M986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The code I am refering to is automatically generated by the Mathworks-RealtimeWorkshop-Embeddedcoder toolset.&amp;nbsp; So I can't easily change the code and I'm trying to sort out where the issue lies.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Per the standard should everything after an #error directive be&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1) treated as 'preprocessing' tokens&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;or&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;2) be treated as a text string&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2007 19:43:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130065#M986</guid>
      <dc:creator>Doug_O</dc:creator>
      <dc:date>2007-04-10T19:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: #error directive format</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130066#M987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;per ANSI C standard, after a #error directive there is an (optional) sequence of preprocessing tokens.&lt;BR /&gt;A string literal ("this is a string") is a legal preprocessing token, but also a identifier, a numbers or most characters are legal preprocessing tokens.&lt;BR /&gt;Single single quotes(') (or single double quotes (")) are explicitely excluded as legal preprocessing tokens, or to be more precise, if they occur the "behavior is undefined" (ANSI-C terminology).&lt;BR /&gt;Can you change your source code so that Mathworks wont issue single quotes?&lt;BR /&gt;"Don't" -&amp;gt; "Do not"?&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2007 20:37:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/error-directive-format/m-p/130066#M987</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2007-04-10T20:37:09Z</dc:date>
    </item>
  </channel>
</rss>

