|
书上的一个讲解多模块的makefile的例,我make时错了。
- compute.h
- double compute(double,double);
- input.h
- double input(char *);
- main.h
- const char *PROMPT1="Enter the value of x:"
- const char *PROMPT2="Enter the value of y:"
- compute.c
- #include "compute.h"
- double compute(doulbe x, double y)
- {
- return(prow((double)x, (double)y);
- }
- input.c
- #include "input.h"
- double input(const char *s)
- {
- float x;
- printf("%s",s);
- scanf("%f",&x);
- return(x);
- }
- main.c
- #include <stdio.h>
- #include "main.h"
- #include "compute.h"
- #include "input.h"
- main()
- {
- double x,y;
- printf("The program takes x and y rtom stdio and display X^y.\n");
- x=input(PROMPT1);
- y=input(PROMPT2);
- printf("x^y is: %6.3f\n",compute(x,y));
- }
- makefile
- power:main.o input.o compute.o
- gcc main.o input.o compute.o -o power -lm
- main.o:main.c main.h input.h compute.h
- gcc -c main.c
- input.o:input.c input.h
- gcc -c input.c
- compute.o:compute.c compute.h
- gcc -c compute.c
复制代码
编译错
[chh@wake c]$ make
gcc -c main.c
In file included from main.c:2:
main.h:2: parse error before "const"
main.c: In function `main':
main.c:11: warning: passing arg 1 of `input' discards qualifiers from pointer target type
main.c:12: `PROMPT2' undeclared (first use in this function)
main.c:12: (Each undeclared identifier is reported only once
main.c:12: for each function it appears in.)
make: *** [main.o] 错误 1 |
|