C struct object Stack - function call is not allowed in constant expression (error)
<p>I am trying to create a struct object (stack) which consists of: </p>

<pre><code>typedef struct node {
    int val;
    struct node * next;
}node_t;

typedef struct {
    node_t * top;
    int max_size;
    int used_size;
} Stack;
</code></pre>

<p>However, when I try to initialize the object and allocate it some memory space using the function:</p>

<pre><code> Stack * newStack(int max_size) {
    Stack * S = malloc(sizeof(Stack));
    S-&gt;top = NULL;
    S-&gt;max_size = max_size;
    S-&gt;used_size = 0;
    return S;
}

Stack * S = newStack(256); //error here
</code></pre>

<p>I get the error referred to above - </p>

<blockquote>
  <p>function call is not allowed in constant expression</p>
</blockquote>

<p>I have never come across this type of error before, and I don't know how to tackle it. Any help is appreciated.</p>