我无法理解 c 头文件和源文件。我有:
某事.c
#include <stdio.h>
#include "something.h"
typedef struct {
int row, col;
} point;
point
whereispoint(point **matrix, int rows, int cols)
{
..... Does something ....
printf("something...");
}
某事.h
typedef struct point * p;
p whereispoint(p **matrix, int rows, int cols);
主程序
#include <stdio.h>
#include "something.h"
int
main(void)
{
int row, col;
p **matrix=malloc(bla, bla);
.....Something.....
p=whereispoint(matrix, row, col);
return 0;
}
现在,当我实际上不知道如何编译它时……我试过gcc -c main.c something.c
了,但这不起作用,我尝试单独编译gcc -c main.c
,gcc -c something.c
然后main.c工作,但something.c没有。
我实际上是在尝试用 something.c 创建一个库,但由于我什至无法将其编译为目标代码,所以我不知道该怎么做。我猜something.h中的结构类型和它的typedef有问题,但我不知道是什么......