Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Extreme C
Extreme C

Extreme C: Taking you to the limit in Concurrency, OOP, and the most advanced capabilities of C

eBook
$26.99 $38.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Extreme C

From Source to Binary

In programming, everything starts with source code. In reality, source code, which sometimes goes by the other name of the code base, usually consists of a number of text files. Within that, each of those text files contains textual instructions written in a programming language.

We know that a CPU cannot execute textual instructions. The reality is that these instructions should first be compiled (or translated) to machine-level instructions in order to be executed by a CPU, which eventually will result in a running program.

In this chapter, we go through the steps needed to get a final product out of C source code. This chapter goes into the subject in great depth, and as such we've split it into five distinct sections:

  1. The standard C compilation pipeline: In the first section, we are going to cover standard C compilation, the various steps in the pipeline, and how they contribute to producing the final product from C source...

Compilation pipeline

Compiling some C files usually takes a few seconds, but during this brief period of time, the source code enters a pipeline that has four distinct components, with each of them doing a certain task. These components are as follows:

  • Preprocessor
  • Compiler
  • Assembler
  • Linker

Each component in this pipeline accepts a certain input from the previous component and produces a certain output for the next component in the pipeline. This process continues through the pipeline until a product is generated by the last component.

Source code can be turned into a product if, and only if, it passes through all the required components with success. This means that even a small failure in one of the components can lead to a compilation or linkage failure, resulting in you receiving relevant error messages.

For certain intermediate products such as relocatable object files, it is enough that a single source file goes through the first three components...

Preprocessor

At the very start of this book in Chapter 1, Essential Features, we introduced, albeit briefly, the concepts of C preprocessor. Specifically, we talked there about macros, conditional compilation, and header guards.

You will remember that at the beginning of the book, we discussed C preprocessing as an essential feature of the C language. Preprocessing is unique due to the fact that it cannot be easily found in other programming languages. In the simplest terms, preprocessing allows you to modify your source code before sending it for compilation. At the same time, it allows you to divide your source code, especially the declarations, into header files so that you can later include them into multiple source files and reuse those declarations.

It is vital to remember that if you have a syntax error in your source code, the preprocessor will not find the error as it does not know anything about the C syntax. Instead, it will just perform some easy tasks, which typically...

Compiler

As we discussed in the previous sections, the compiler accepts the translation unit prepared by the preprocessor and generates the corresponding assembly instructions. When multiple C sources are compiled into their equivalent assembly code, the existing tools in the platform, such as the assembler and the linker, manage the rest by making relocatable object files out of the generated assembly code and finally linking them together (and possibly with other object files) to form a library or an executable file.

As an example, we spoke about as and ld as two examples among the many available tools in Unix for C development. These tools are mainly used to create platform-compatible object files. These tools exist necessarily outside of gcc or any other compiler. By existing outside of any compiler, we actually mean that they are not developed as a part of gcc (we have chosen gcc as an example) and they should be available on any platform even without having gcc installed....

Assembler

As we explained before, a platform has to have an assembler in order to produce object files that contain correct machine-level instructions. In a Unix-like operating system, the assembler can be invoked by using the as utility program. In the rest of this section, we are going to discuss what can be put in an object file by the assembler.

If you install two different Unix-like operating systems on the same architecture, the installed assemblers might not be the same, which is very important. What this means is that, despite the fact that the machine-level instructions are the same, because of being on the same hardware, the produced object files can be different!

If you compile a program and produce the corresponding object file on Linux for an AMD64 architecture, it could be different from if you had tried to compile the same program in a different operating system such as FreeBSD or macOS, and on the same hardware. This implies that while the object files cannot...

Linker

The first big step in building a C project is compiling all the source files to their corresponding relocatable object files. This step is a necessary step in preparing the final products, but alone, it is not enough, and one more step is still needed. Before going through the details of this step, we need to have a quick look at the possible products (sometimes referred to as artifacts) in a C project.

A C/C++ project can lead to the following products:

  • A number of executable files that usually have the .out extension in most Unix-like operating systems. These files usually have the .exe extension in Microsoft Windows.
  • A number of static libraries that usually have the .a extension in most Unix-like operating systems. These files have the .lib extension in Microsoft Windows.
  • A number of dynamic libraries or shared object files that usually have the .so extension in most Unix-like operating systems. These files have the .dylib extension in macOS, and...

Summary

In this chapter, we covered the fundamental steps and components required to build a C project. Without knowing how to build a project, it is pointless to just write code. In this chapter:

  • We went through the C compilation pipeline and its various steps. We discussed each step and described the inputs and the outputs.
  • We defined the term platform and how different assemblers can lead to different machine-level instructions for the same C program.
  • We continued to discuss each step and the component driving that step in a greater detail.
  • As part of the compiler component, we explained what the compiler frontends and backends are, and how GCC and LLVM use this separation to support many languages.
  • As part of our discussion regarding the assembler component, we saw that object files are platform-dependent, and they should have an exact file format.
  • As part of the linker component, we discussed what a linker does and how it uses symbols to find the missing...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Make the most of C’s low-level control, flexibility, and high performance
  • A comprehensive guide to C’s most powerful and challenging features
  • A thought-provoking guide packed with hands-on exercises and examples

Description

There’s a lot more to C than knowing the language syntax. The industry looks for developers with a rigorous, scientific understanding of the principles and practices. Extreme C will teach you to use C’s advanced low-level power to write effective, efficient systems. This intensive, practical guide will help you become an expert C programmer. Building on your existing C knowledge, you will master preprocessor directives, macros, conditional compilation, pointers, and much more. You will gain new insight into algorithm design, functions, and structures. You will discover how C helps you squeeze maximum performance out of critical, resource-constrained applications. C still plays a critical role in 21st-century programming, remaining the core language for precision engineering, aviations, space research, and more. This book shows how C works with Unix, how to implement OO principles in C, and fully covers multi-processing. In Extreme C, Amini encourages you to think, question, apply, and experiment for yourself. The book is essential for anybody who wants to take their C to the next level.

Who is this book for?

Extreme C is for C programmers who want to dig deep into the language and its capabilities. It will help you make the most of the low-level control C gives you.

What you will learn

  • Build advanced C knowledge on strong foundations, rooted in first principles
  • Understand memory structures and compilation pipeline and how they work, and how to make most out of them
  • Apply object-oriented design principles to your procedural C code
  • Write low-level code that's close to the hardware and squeezes maximum performance out of a computer system
  • Master concurrency, multithreading, multi-processing, and integration with other languages
  • Unit Testing and debugging, build systems, and inter-process communication for C programming

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 31, 2019
Length: 822 pages
Edition : 1st
Language : English
ISBN-13 : 9781789341355
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 31, 2019
Length: 822 pages
Edition : 1st
Language : English
ISBN-13 : 9781789341355
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 189.97
Hands-On Network Programming with C
$46.99
Extreme C
$54.99
C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development
$87.99
Total $ 189.97 Stars icon

Table of Contents

26 Chapters
Essential Features Chevron down icon Chevron up icon
From Source to Binary Chevron down icon Chevron up icon
Object Files Chevron down icon Chevron up icon
Process Memory Structure Chevron down icon Chevron up icon
Stack and Heap Chevron down icon Chevron up icon
OOP and Encapsulation Chevron down icon Chevron up icon
Composition and Aggregation Chevron down icon Chevron up icon
Inheritance and Polymorphism Chevron down icon Chevron up icon
Abstraction and OOP in C++ Chevron down icon Chevron up icon
Unix – History and Architecture Chevron down icon Chevron up icon
System Calls and Kernels Chevron down icon Chevron up icon
The Most Recent C Chevron down icon Chevron up icon
Concurrency Chevron down icon Chevron up icon
Synchronization Chevron down icon Chevron up icon
Thread Execution Chevron down icon Chevron up icon
Thread Synchronization Chevron down icon Chevron up icon
Process Execution Chevron down icon Chevron up icon
Process Synchronization Chevron down icon Chevron up icon
Single-Host IPC and Sockets Chevron down icon Chevron up icon
Socket Programming Chevron down icon Chevron up icon
Integration with Other Languages Chevron down icon Chevron up icon
Unit Testing and Debugging Chevron down icon Chevron up icon
Build Systems Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Leave a review - let other readers know what you think Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(28 Ratings)
5 star 75%
4 star 10.7%
3 star 3.6%
2 star 7.1%
1 star 3.6%
Filter icon Filter
Top Reviews

Filter reviews by




Michael Van de Velde Aug 29, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very good book. Shipped fast. The chapters on OOP in C are really strong. Would gift this book to anybody who's trying to become a C master.
Amazon Verified review Amazon
Martin Gruscher Mar 07, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This one hit me by surprise. Of course I would be a book which contains "Extreme C" in its title :)Still I did not have any expectations, hoping I would get a decent treatment of C Programming, but it was really much more.A wonderful piece about programming and the inner workings of computers in general. I very much enjoyed the style of this author. This is easily one of my favourite IT/Programming books.
Amazon Verified review Amazon
ebjafer Jul 14, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Alles ok !
Amazon Verified review Amazon
Michael Nov 10, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
the book is introducing concepts and demonstrate them with examples alongwith what could go wrong.laid out very nicely and references for more information is also given in case youfeel the need to go a bit deeper...i recommend reading the first two chapters even if you know some C.[EDIT]i didn't knew C as good as i thoughta must have classic on C.
Amazon Verified review Amazon
Donald Bosley May 04, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've come to associate Packt as the publisher where anyone with a word processor can get published. This is not one of those books. This is far and away the deepest, most well written text I own on modern C. If there can only be one C book in your collection, this is it (Sorry K&R...). Material is well organized, concepts are clear, and the author's personal philosophies are suggestive rather than authoritarian (although he strikes me as an authority...). I'm 13 years deep in C, and 3 years in on owning this text and I keep re-opening it because the material is that rich. The "OOP in C" chapters are fairly unique for a C book, and probably my favorite sections - they've helped me codify how I think about embedded software stacks and re-usable code. The real "extreme" here, is the simultaneous breadth of topics covered along with their depths. Fantastic resource.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.