test.h
#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED
int func(void);
typedef int (*FPTR)(void);
#endif // TEST_H_INCLUDED
func.c
#include "test.h"
static int x = 22; // persistent with external linkage.
int func(void)
{
extern int x; // Referencing declaration
static int count = 0; // persistent within block
printf("%d : %d\n",++count,++x);
return 1;
}
FPTR funcptr = func; // persistent with external linkage. ??
main.c
#include "test.h"
#include <stdio.h>
extern funcptr; // referencing declaration ??
int main(void)
{
func();
funcptr(); // Compile Time Error Here
return 0;
}
此操作失败,并显示错误called object ‘funcptr’ is not a function or function pointer
。
我在这里违反任何基本规定吗?
答案 0 :(得分:4)