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版)
718
|
第
20
章
宏
installtarget
所包含的变量引用会按上述形式被完整地保留下来,只有当
make
展开
$(installtarget)
自身
时,整个变量才会被展开,例如:
circle: $(OBJ) $(LIB)
$(CC) $(LDFLAGS)
-
o $@ $^
ifdef INSTALLTOO
$(installtarget)
endif
20.9 函数
GNU
make
不仅仅可以简单地展开宏,还提供了函数功能,包括内置函数和用户自定义
函数。通过使用参数、条件以及内置函数,可以定义功能强大的函数,并在
makefile
中
的任意位置使用它们。
在
makefile
中调用函数的语法类似于引用宏,需要用到美元符号和圆括号:
$(
function_name argument
[,
argument
[,...]])
参数列表中空格的意义很重要。
make
会忽略第一个参数之前的空格,但是如果在逗
号前面或后面加入空格,
make
会把这样的空格视为参数值的一部分。
参数本身可以包含任何字符,除了嵌入其中的逗号。圆括号必须成对出现,否则
make
在
处理函数调用时会出问题。如有必要,可以定义一个变量来保存逗号或括号字符,并将
一个变量引用作为函数参数,来避免前述限制。
20.9.1 内置函数
GNU
make
提供了超过
20
个文本处理和流程控制函数,后面各节会简要介绍。
20.9.1.1 文本处理函数
本节列举的文本处理函数对于操作
make
变量的值非常有用,这些变量值通常是字符序列:
$(subst
find_text ...
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