単純なプログラムですが、このコンパイラエラーが発生し続けます。コンパイラーにMinGWを使用しています。
これがヘッダーファイルpoint.hです:
//type for a Cartesian point
typedef struct {
double x;
double y;
} Point;
Point create(double x, double y);
Point midpoint(Point p, Point q);
そしてここにpoint.cがあります:
//This is the implementation of the point type
#include "point.h"
int main() {
return 0;
}
Point create(double x, double y) {
Point p;
p.x = x;
p.y = y;
return p;
}
Point midpoint(Point p, Point q) {
Point mid;
mid.x = (p.x + q.x) / 2;
mid.y = (p.y + q.y) / 2;
return mid;
}
そして、ここでコンパイラの問題が発生します。私は次のことを続けています。
testpoint.c:'create(double x、double y)'への未定義の参照
それはpoint.cで定義されていますが。
これはtestpoint.cと呼ばれる別のファイルです:
#include "point.h"
#include <assert.h>
#include <stdio.h>
int main() {
double x = 1;
double y = 1;
Point p = create(x, y);
assert(p.x == 1);
return 0;
}
問題が何であるかについて私は途方に暮れています。