一、文件test_funcs.c:
#include <stdio.h>
#include <stdlib.h>
struct t_Test
{
int n1;
int n2;
};
struct t_Test *alloc_Test(void)
{
struct t_Test *pTest=NULL;
pTest=malloc(sizeof(struct t_Test));
pTest->n1 = 1;
return pTest;
}
void func1(struct t_Test *pTest)
{
printf("%s\n",__FUNCTION__);
printf("n1:%d\n",pTest->n1);
return;
}
二、文件test.c:
#include <stdio.h>
extern struct t_Test *alloc_Test(void);
extern void func1(struct t_Test *pTest);
void main(void)
{
struct t_Test *pTest=NULL;
pTest=alloc_Test();
func1(pTest);
return;
}
三、编译:
gcc test.c test_funcs.c -o test
</