问题描述
我正在尝试使用Makefile构建C程序,但不幸的是,即使转义并尝试了其他转义技术,尝试调用已定义的变量时也会出错。
文本文件greetings-file.txt包含字符串"Goodnight Moon!\n"
这是我的代码:
F= greetings-file.txt
M= Makefile-hello
# complete the makefile as instructed in the quiz2.txt file # you will need to add dependencies after the target(s)
# as well as actions in the recipes
program: hello
@echo run hello
./hello
hello.c:
@echo make hello.c based on $F and $M
@echo "#include<stdio.h>" > hello.c
@echo "int main(){printf(\"`cat $F`\");}" >> hello.c
hello: hello.c
@echo compile hello.c
cc -o hello hello.c
clean:
@echo cleanup hello
-rm hello hello.c
这是我的错误:
compile hello.c
cc -o hello hello.c
hello.c: In function ‘main’:
hello.c:2:21: error: expected ‘)’ before ‘Goodnight’
int main(){printf(""Goodnight Moon!
^~~~~~~~~
hello.c:2:19: warning: zero-length gnu_printf format string [-Wformat-zero-length]
int main(){printf(""Goodnight Moon!
^~
Makefile-hello:27: recipe for target 'hello' failed
make: *** [hello] Error 1
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)