Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
LINUX系統程式設計 第二版
by
Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from
LINUX系統程式設計 第二版
GCC
對
C
語言所做的擴充
|
435
案例範圍
GCC
允許
case
敘述標籤為單一區塊指定一個範圍值。語法如下:
case low... high:
例如:
switch (val) {
case 1 ... 10:
/* ... */
break;
case 11 ... 20:
/* ... */
break;
default:
/* ... */
}
此功能對於
ASCII
的案例範圍(
case range
)也相當有用:
case 'A' ... 'Z':
注意,省略符號(
...
)的前後應該要有一個空格。否則,編譯器可能會被搞混,尤其是
在使用整數範圍的時候。所以你一定要這麼做:
case 4 ... 8:
不要這麼做:
case 4...8:
void
以及函式指標計算
GCC
允許對指向
void
型別的指標以及指向函式的指標進行加法以及減法的計算。一般
而言,
ISO C
並不允許對此類指標進行計算,因為「
void
的大小」是一個愚蠢的想法,
而且取決於指標實際所指向的物件。為了讓此類計算容易進行,
GCC
把所指向物件的大
小視為一個位元組。因此,如下的程式碼片段便可以讓
a
前進一步:
a++; /* a
是一個
void
指標
*/
選項
-Wpointer-arith
用於提示
GCC
在使用此擴充功能時產生一個警告訊息。
436
|
附錄
A
更具移植性並且更美觀
老實說,
__attribute__
的語法並不美觀。本章所提到的擴充功能,有一些需要使用預處
理器巨集以便粉飾其外觀,好讓它們的使用賞心悅目。
這並不難,只需要用到些許的預處理器魔法 ...
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.
Start your free trial
You might also like
優雅的SciPy|Python科學研究的美學
Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
成為卓越程式設計師的38項必修法則
Pete Goodliffe
深入理解運算原理|從簡單的機器到無所不能的程式
Tom Stuart
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9789862769812