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版)
254
|
第
15
章
有两种方法可以验证
C
预处理器的运行结果:通过作为一个独立的程序运行预处理器,
或者通过使用编译器选项设定仅仅执行预处理步骤。
15.1 插入头文件的内容
#include
命令告诉预处理器将指定头文件的内容插入到预处理器命令的相应位置。有两
种方式可以指定插入头文件:
#include <
文件名
>
#include "
文件名
"
如果需要包含标准库头文件或者实现版本所提供的头文件,应该使用第一种格式。如下
例所示:
#include <math.h> //
一些数学函数的原型,以及相关的类型和宏
如果需要包含针对程序所开发的源文件,则应该使用第二种格式。采用
#include
命令所
插入的文件,通常文件扩展名是
.h
,文件包括函数原型、宏定义和类型定义。只要使用
#include
命令,这些定义就可被任何源文件使用。如下例所示:
#include "myproject.h" //
用在当前项目中的函数原型、类型定义和宏
你可以在
#include
命令中使用宏。如果使用宏,该宏的取代结果必须确保生成正确的
#include
命
令。例
15-1
展示了这样的
#include
命令。
例
15-1
:在
#include
命令中的宏
#ifdef _DEBUG_
#define MY_HEADER "myProject_dbg.h"
#else
#define MY_HEADER "myProject.h"
#endif
#include MY_HEADER
当上述程序代码进入预处理时,如果
_DEBUG ...
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