Ric*_*ard 25 c makefile compilation
是否可以将#define VAR(在C程序中)的等价物放入makefile中,以便可以控制程序的哪一部分应该编译?
Zim*_*bao 21
相应的手册cc页linux
-D name=definition
The contents of definition are tokenized and processed as if they appeared during translation phase three in a #define directive. In
particular, the definition will be truncated by embedded newline characters.
Run Code Online (Sandbox Code Playgroud)
Ant*_*neL 12
编辑你Makefile的节目
CFLAGS = -D VAR1 -D VAR2 =*某事*
如果您在Makefile中使用默认规则,则应该自动运行.如果你不这样做,并且明确地调用C编译器,那么请确保你正在写一些东西
$(CC)$(CFLAGS)-c -o $ @ $ <
如果CFLAGS=...上面的事实可以在命令行上使用而不是写在Makefile中(阅读man(1)手册页),那就更可爱了; 这样可以在最后时刻轻松重新配置编译参数,但不会保留参数.
最佳实践包括使用CPPFLAGS替代CFLAGS,并使用+=替代=; 但是对这些功能的支持并不像上面那样普遍,并且取决于你的make系统.
| 归档时间: |
|
| 查看次数: |
37286 次 |
| 最近记录: |