函数指针typedef的前向声明

我遇到了一个特殊的问题.最好只是向您展示我正在尝试做什么,然后解释它.
typedef void functionPointerType ( struct_A * sA );

typedef struct
{
    functionPointerType ** functionPointerTable;
}struct_A;

基本上,我有一个结构struct_A,其中包含一个指向函数指针表的指针,这些函数指针的参数类型为struct_A.但我不确定如何进行编译,因为我不确定如何或是否可以转发声明这一点.

谁知道如何实现这一目标?

编辑:代码中的小修复

解决方法

按照你的建议转发声明:
/* Forward declare struct A. */
struct A;

/* Typedef for function pointer. */
typedef void (*func_t)(struct A*);

/* Fully define struct A. */
struct A
{
    func_t functionPointerTable[10];
};

例如:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct A;

typedef void (*func_t)(struct A*);

struct A
{
    func_t functionPointerTable[10];
    int value;
};

void print_stdout(struct A* a)
{
    printf("stdout: %d\n",a->value);
}

void print_stderr(struct A* a)
{
    fprintf(stderr,"stderr: %d\n",a->value);
}

int main()
{
    struct A myA = { {print_stdout,print_stderr},4 };

    myA.functionPointerTable[0](&myA);
    myA.functionPointerTable[1](&myA);
    return 0;
}

输出

stdout: 4
stderr: 4

参见在线演示http://ideone.com/PX880w.

正如其他人已经提到的那样,可以添加

typedef struct A struct_A;

如果最好省略struct关键字,则在函数指针typedef和struct A的完整定义之前.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...