我正在尝试在visual studio 2010中编译以下文件:
本教程取自here
/ * callback.c * /
#include<stdio.h>
#include"reg_callback.h"
/* callback function definition goes here */
void my_callback(void)
{
printf("inside my_callback\n");
}
int main(void)
{
/* initialize function pointer to
my_callback */
callback ptr_my_callback=my_callback;
printf("This is a program demonstrating function callback\n");
/* register our callback function */
register_callback(ptr_my_callback);
printf("back inside main program\n");
return 0;
}
/ * reg_callback.h * /
typedef void (*callback)(void);
void register_callback(callback ptr_reg_callback);
/ * reg_callback.c * /
#include<stdio.h>
#include"reg_callback.h"
/* registration goes here */
void register_callback(callback ptr_reg_callback)
{
printf("inside register_callback\n");
/* calling our callback function my_callback */
(*ptr_reg_callback)();
}
但是我收到了这个链接错误:
错误1错误LNK2019:未解析的外部符号&#34; void __cdecl register_callback(void(__ cdecl *)(void))&#34; (?register_callback @@ YAXP6AXXZ @ Z)在函数中引用 _main D:\ VS \ test \ ww \ ww \ ww.obj ww
这里有什么问题我无法理解。请帮助。