Skip to Content
C语言核心技术(原书第2版)
book

C语言核心技术(原书第2版)

by Peter Prinz, Tony Crawford
August 2017
Intermediate to advanced
798 pages
17h 44m
Chinese
China Machine Press
Content preview from C语言核心技术(原书第2版)
使用
make
构建
C
程序
|
707
使用
make
构建
C
程序
如果一条命令包含了
#
符号(也就是说,如果该行以一个制表符作为开始),那么该行
不能包含一个
make
注释。如果需要创建相应的目标,为了执行
shell
命令,
make
会向
shell
传入整个命令行,并去掉领头的制表符。(某些
shell
,例如
Bourne shell
,也会把
#
符号
翻译为注释的开始,但是这超越了
make
所能控制的范围。
)
20.5 变量
在
make
中,所有的变量都属于相同的类型:它们包含字符序列,而不是数值。当
make
采用一个规则时,它会计算包含在目标、依赖条件和命令中的所有变量。
GNU
make
中
的变量有两种:一种是递归展开(
recursively expanded
)的变量,另一种是简单展开
(
simply expanded
)的变量。对于给定的变量,所属哪种类型取决于在定义时使用的是
哪种赋值运算符。在一个递归展开变量中,嵌套的变量引用都被存储下来,直到该变量
的值被计算出来。另一方面,在简单展开变量中,变量引用会在赋值时即刻展开,并且
展开的值会被存储下来,而不是存储变量名称。
变量名可以包括任何字符,除了:、=和
#
之外。然而,基于对
makefile
鲁棒性和对
shell
兼容性的考虑,最好只使用字母、数字和下划线字符。
20.5.1 赋值运算符
采用何种赋值运算符来定义一个变量,决定了该变量是简单展开还是递归展开的变量。
下面的示例使用赋值运算符=,这会建立一个递归展开变量:
DEBUGFLAGS = $(CFLAGS) -ggdb -DDEBUG ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)

Publisher Resources

ISBN: 9787111562207