【发布时间】:2013-03-01 23:37:55
【问题描述】:
main.c:
#include <stdio.h>
#include "proto.h"
int main(void)
{
return(0);
} // end main
support.c:
#include "proto.h"
\\ only function defintions
proto.h:
#ifndef proto
#define proto
double PI = 3.14159;
int LOOP_LIMIT = 90;
#endif
制作文件:
main: main.o support.o
gcc -lm -o main main.o support.o
main.o: main.c proto.h
gcc -c main.c
support.o: support.c proto.h
gcc -c support.c
每当我使用上述定义的文件运行 makefile 时,我总是会遇到多重定义错误,尽管有条件编译。
我不确定这里发生了什么以及如何解决问题。
错误信息是:
multiple definition of `PI'
multiple definition of `LOOP_LIMIT'
【问题讨论】:
-
包含实际的错误信息。
标签: c linux makefile definition multiple-definition-error