title: How to change macro definitions via make in C
body: <p>So I am making a C program which get's its memory from a <code>static unsigned char[M_SIZE]</code> array, where <code>M_SIZE</code> is a macro. What I need to do is to be able to change the value of that macro via a command in make, such that someone could compile the program with a different size of reserved memory depending on arguments passed to make.</p>
  
  <p>My header file example is DataStore.h</p>
  
  <pre><code>#ifndef DATA_STORE_H
  #define DATA_STORE_H
  
  #define M_SIZE 50000 // Need this to be configurable via make arguments
  
  unsigned char* DataStore_get_buf(void);
  unsigned char* DataStore_get_end(void);
  void DataStore_inc_ptr(void);
  
  #endif
  </code></pre>
  
  <p>My example C file is DataStore.c</p>
  
  <pre><code>#include "DataStore.h"
  
  static unsigned char DataStore_BUFFER[M_SIZE];
  static unsigned char* DataStore_PTR = DataStore_BUFFER;
  
  unsigned char* DataStore_get_buf(void)
  {
     return DataStore_BUFFER;
  }
  
  unsigned char* DataStore_get_end(void)
  {
     return DataStore_BUFFER + M_SIZE;
  }
  
  void DataStore_inc_ptr(void)
  {
      DataStore_PTR++;
  }
  </code></pre>
  
  <p>So Basically, I need a way to change M_SIZE before the program is compiled via some command or some configuration that can be passed into make.</p>
  
  <p>Edit1:</p>
  
  <p>This question is unique because I need a method to not just pass in a configurable macro value, but handle the case in which that value isn't passed in as a command, and a default macro value is used instead.</p>