Many of you are familiar with the C and C++ languages. You know the syntax and the semantics of the various operations and have a feel for what is allowed by the language according to its specification. However, you may (or may not) be surprised to discover that compilers for these languages deviate from the official specifications.
Many of you are familiar with the C and C++ languages. You know the syntax and the semantics of the various operations and have a feel for what is allowed by the language according to its specification. However, you may (or may not) be surprised to discover that compilers for these languages deviate from the official specifications.
For the most part, compilers perform all of the necessary functions to get your programs running, but they often add features to the language that are not in the language specification. These additional features can be included for a number of different reasons — to aid programmers in writing code or to fill in supposed deficiencies in the language, for example.
This month, we’re going to explore some of the language extensions found in gcc and g++. We’ll also spend a little time looking at how and why they’re used.
One notable project that makes use of these extensions is the Linux kernel. If you’re doing any work at the kernel level, it’s definitely worth your time to familiarize yourself with these GCCisms.
That said, before diving in and making wide use of these language extensions, it’s a good idea to do a bit of advance planning. The moment you start using one of these features, you must be sure that the application you are developing will only be compiled with gcc or g++. The Linux kernel can make this assumption, but chances are that other applications cannot. If…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: