title: How to pass macro definition from "make" command line arguments (-D) to C source code?
body: <p>I usually pass macro definitions from "make command line" to a "makefile" using the option :
  -Dname=value. The definition is accessible inside the makefile.</p>
  
  <p>I also pass macro definitions from the "makefile" to the "source code" using the similar compiler option :
  -Dname=value (supported in many compilers). This definition is accessible in the source code.</p>
  
  <p>What I need now, is to allow the user of my makefile to be able to pass arbitrary macro definitions from the "make.exe commandline" to "source code" right away, without having to change anything in the makefile.</p>
  
  <p>so the user can type :
  make -f mymakefile.mk -SOMEOPTION var=5</p>
  
  <p>then directly the code main.c can see var :</p>
  
  <pre><code>int main()
  {
    int i = var;
  }
  </code></pre>