<?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: Selective compile in C</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206154#M7945</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your welcome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's good to know you manage to solve it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Feb 2012 19:45:32 GMT</pubDate>
    <dc:creator>sebasira</dc:creator>
    <dc:date>2012-02-23T19:45:32Z</dc:date>
    <item>
      <title>Selective compile in C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206151#M7942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using CW6.3 for HCS08 devices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My project uses a generalised array of function pointers -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;// Table of user function pointers for each timeslot:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;static const void (*Usr_func[])(void) = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp;&amp;nbsp; Usr0_tic4,&amp;nbsp; Usr1_tic4, Usr0_tic8, Usr1_tic8,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp;&amp;nbsp; Usr0_tic16, Usr1_tic16, Usr2_tic16, Usr3_tic16 };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, a specific version of the project may not&amp;nbsp;make use of&amp;nbsp;all of the functions. For each unused function, I would like to be able to &lt;SPAN style="text-decoration: underline;"&gt;automatically&lt;/SPAN&gt;&amp;nbsp;incorporate an empty function as a default, e.g.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;void Usr0_tic4( void) { }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I have not been able to find a suitable #ifndef that achieves the desired result.&amp;nbsp; Within the primary project file, I would like to restrict the code to only those functions that are used, if at all possible.&amp;nbsp; The separate file containing the array would be standardised, and not require to&amp;nbsp;be altered for different projects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This concept works well for assembly code, where selective assembly, based on a non-defined subroutine name, is feasible.&amp;nbsp; I would like to do as similar thing with the C coded version.&amp;nbsp; Perhaps someone can suggest a method.&amp;nbsp; Otherwise, I will need to incorporate all the functions within the primary project file, whether utilised or not (which is probably not the "end of the world").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2012 22:54:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206151#M7942</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-02-14T22:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Selective compile in C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206152#M7943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mac!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If only C support function overriding....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess maybe the best shot is to use some macros (labels) instead of the function name inside the array; and&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;also a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;dummy routine so you will have:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Stardard file: (the one with the array):&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;void dummy (void){}/* So you can handle unused functions these way */#ifndef U0_T4    #define U0_T4      dummy#endif#ifndef U1_T4    #define U1_T4      dummy#endif#ifndef U0_T8    #define U0_T8      dummy#endif
// and so on for every function inside the array// Table of user function pointers for each timeslot:static const void (*Usr_func[])(void) = {   U0_T4,  U1_T4, U0_T8, U1_T8,   U0_T16, U1_T16, U2_T16, U3_T16 };&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Your project file:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;/* Assuming you only use Usr1_tic4 and Usr0_tic8 */#define U1_T4      Usr1_tic4  #define U0_T8      Usr0_tic8&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sadly it would mean a major update to your code, but you won't need a dummy function for each not-used routine&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope it helps,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best Regards!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 03:03:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206152#M7943</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-02-23T03:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Selective compile in C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206153#M7944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sebastian,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thankyou for your response.&amp;nbsp;&amp;nbsp;I was able to implement it without too much change to the existing code.&amp;nbsp; I&amp;nbsp;created an additional header file (Usr_Project.h) to contain the relevant function macros for the project, and this is #included within the "System.c" file where the #ifndef's and the function pointer array are located.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am kicking myself&amp;nbsp;for not recognizing this limitation of&amp;nbsp;the preprocessor, especially since I recently proposed a similar method for the preprocessor recognition of variable names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 19:27:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206153#M7944</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-02-23T19:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Selective compile in C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206154#M7945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your welcome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's good to know you manage to solve it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 19:45:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206154#M7945</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-02-23T19:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Selective compile in C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206155#M7946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On a related issue, I&amp;nbsp;usually experience difficulty with the use of the 'const' keyword, when applied to pointers and functions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I previously posted the array of function pointers -&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;// Table of user function pointers for each timeslot:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;const void (*Usr_func[])(void) = { ...&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;};&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I did not realize at the time, that the array was actually located in RAM, rather than within&amp;nbsp;flash.&amp;nbsp; With a cross-reference to the format of a vector table, the following incantation placed the array in flash, as required.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;void (*const Usr_func[])(void) = { ... };&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I then successfully tried using&amp;nbsp;the following&amp;nbsp;typdef and array definition, for the array to&amp;nbsp;locate in flash -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;typedef void (*funcptr0)(void);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;const funcptr0 Usr_func[] = { ... };&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I still have diffulty in understanding how the last two methods become equivalent.&amp;nbsp; I am obviously missing something.&amp;nbsp; Perhaps someone&amp;nbsp;would be willing to&amp;nbsp;give me an explanation.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 19:59:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206155#M7946</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-02-23T19:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Selective compile in C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206156#M7947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you define:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;const void (*Usr_func[])(void) = { ...&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;};&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The pointer is a variable (RAM) and the type returned by the functions are constant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you define:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void (*const Usr_func[])(void) = { ... };&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Now the pointer is constant so it's placed in FLASH&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And in&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;const funcptr0 Usr_func[] = { ... };&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;you're saying that the type is constant.... So if the type is a pointer to function, then is a constant pointer to function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 21:33:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Selective-compile-in-C/m-p/206156#M7947</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-02-23T21:33:14Z</dc:date>
    </item>
  </channel>
</rss>

