Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have one microcontroller but several projects which get compiled from the same source code. I think my scenario is similar to yours, at least to some extent. My solution was inspired by Linux kernel, as well.</p> <h2><code>config.h</code></h2> <p>All source code which needs to get access to some configuration parameter simply includes an header file called <code>config.h</code>.</p> <p><code>config.h</code> consists of just one line:</p> <pre><code>#include &lt;config/project.h&gt; </code></pre> <h2><code>project.h</code></h2> <p>I have several configuration header files, one per project. A <code>project.h</code> consists of macro definitions with values such as <code>true</code>, <code>false</code>, or constants:</p> <pre><code>#define CONFIG_FOO true #define CONFIG_BAR false #define CONFIG_TIME 100 </code></pre> <h2><code>check.c</code></h2> <p>This file checks configuration parameters for correctness: - all parameters <strong>must</strong> be defined, even if not used or meaningful for that project - unwanted parameter combinations are signalled - parameter values are constrained.</p> <pre><code>#if !defined(CONFIG_FOO) #error CONFIG_FOO not defined #endif #if !defined(CONFIG_BAR) #error CONFIG_BAR not defined #endif #if !defined(CONFIG_TIME) #error CONFIG_TIME not defined #endif #if !(CONFIG_FOO ^ CONFIG_BAR) #error either CONFIG_FOO or CONFIG_BAR should be se #endif #if CONFIG_TIME &gt; 250 #error CONFIG_TIME too big #endif </code></pre> <h2><code>Makefile</code></h2> <p>By instructing the compiler to output the preprocessor macros, it is possible (with a bit of <code>sed</code> expression) to feed the <code>Makefile</code> with the same parameter values gprovided for a given project.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload