Circular dependency between declaration of struct and function pointer
<p>I have a struct which has a function pointer as a member variable. The function pointer takes a pointer to the struct as one of its parameters. </p>

<p>By looking at solutions posted on here for such circular dependencies I used a forward declaration to be able to compile. </p>

<p>I still have the problem of not being able to initialize the struct. Posted below is the code and the output.</p>

<p>edit: My earlier MVCE didn't reproduce the problem correctly. I can get this to compile by naming the struct instead of just having a struct alias. Not exactly sure why though.</p>

<pre><code>#include "stdio.h"

//Forward declaration
struct data;

typedef int(*funcPtr) (struct data* a);

typedef struct
{
    int a;
    int b;
    funcPtr foo;
}data;

int foo(data* pData)
{
    return 0;
}

static data testData[] = {{1,1,foo}, {0,2,foo},};

int main()
{
    printf("Just trying to compile this program\n");
    return 0;
}
</code></pre>

<p>Error output --</p>

<pre><code>compileError.c:20:1: warning: initialization from incompatible pointer type [enabled by default]
static data testData[] = {{1,1,foo}, {0,2,foo},};
^
compileError.c:20:1: warning: (near initialization for \u2018testData[0].foo\u2019) [enabled by default]
compileError.c:20:1: warning: initialization from incompatible pointer type [enabled by default]
compileError.c:20:1: warning: (near initialization for \u2018testData[1].foo\u2019) [enabled by default
</code></pre>