title: how to initialize a global const pointer?
body: <p>I have a variable which is the head to a linked list.  I want to make it const because it should never be changed, the variable is used throughout the program, so I thought I should make it a global const.  The problem is that I couldn't initialize it after I declared it const.  </p>
  
  <p>How can I get around this problem?</p>
  
  <pre><code>typedef struct PT {
   int x;
   int y;
   struct PT *next;
  } POINT;
  
  //globals
  POINT * const mypoint_head;
  
  int main(int argc, char *argv[])
  {
      int size = 100;
      mypoint_head= InitPoint(size);   // error C2166: l-value specifies const object
      //rest of code
  
  }
  
  
  POINT* InitPoint(int size)
  {
     POINT *tmp;
     POINT *orig;
     int a = 10;
     int b = 1000;
     orig = (POINT*) malloc (sizeof(POINT) * size);
     if(orig == NULL)
        return NULL;
  
     tmp = orig;
     for (i = 0; i &lt; size; i++)
     {
        tmp-&gt;x = a++;
        tmp-&gt;y = b++;
        if (i == size -1) {
              tmp-&gt;next = NULL:
        }
        else {
              tmp-&gt;next = tmp+1; 
        }
        tmp++;
     }
     return orig;
  } 
  </code></pre>