Mike Slinn
Mike Slinn

C and C++ Online and On Ubuntu

Published 2023-05-12. Last modified 2023-05-14.
Time to read: 3 minutes.

This page is part of the posts collection, categorized under C & C++, Visual Studio Code, Zamples.

Recently I decided to brush up on my C programming.

I first discovered C during a visit in 1978 to the Computer Science department of University of California, Berkeley, where I also encounted UNIX for the first time.

From about 1983 to 1985 I was the unofficial Canadian distributor of the Lattice C compiler. I used that compiler for most of the programming work I was doing on PCs at the time. FedEx Express Canada did not come into being until 1987, UPS was even worse with the Canadian border than it is now, and Canada Post took forever to bring packages across the border. I bought in bulk at a discount, and sold at list price. Distribution is all about time and place.

I also sold the first edition of the K&R book (“The C Programming Language”) via mail order, and I provided technical support, which brought in interesting consulting work.

The Borland Turbo C compiler, released in 1990, was the original IDE. It was eventually replaced by Borland C++ compiler, which also compiled C. In 2005 I became the product marketing manager for most of Borland’s compilers. One of my responsibilities was to give free copies to book authors and members of the trade press. Borland C++ shipped in a massive box that was responsible for a lot of dead trees.

The C language has evolved since K&R days. The current and previous iterations are well summarized on cppreference.com, which also provides an online C/C++ IDE for sample code.

Revision History

1978: K&R book first published.

1989: C89, also known as ANSI X3. 159-1989, or ANSI C.

1995: NA1 (aka C94 and C95) added support for wide-characters, wide-strings, and international keyboard layouts.

1999: C99 added restricted pointers, variable-length arrays, flexible array members, complex numbers support, type-generic math, long long int, extended identifiers, hexadecimal floating-point constants, compound literals, designated initializers, single line comments, extended integer type, the ability to mix declarations and code, variadic macros, new math functions, inline functions, boolean types, _Pragma and standard pragmas, and VA_COPY. C99 removed implicit function declaration.

2011: C11 added concurrency support, type-generic expressions, alignment-related facilities, static assertion, Unicode support, floating-point characteristic macros, no-return functions, anonymous structures and unions, bound-checking, and reentrancy functions.

2018: C18 addressed defects in C11 without introducing new language features.

2023: The most recent publicly available draft of the next release, C23, was released on April 1, 2023. Unfortunately, that document was written for insiders, and is very difficult to read. Happily, JeanHeyd Meneide, the Project Editor for ISO/IEC JTC1 SC22 WG14 - Programming Languages, C, wrote an easy-to-read summary of C23.

Linux Is Written in C

It has been reported that Linux was originally written in C89, but Linux moved to C11 in 2022. I am curious as to why C18 is not used, since C18 just contains bug fixes for C11. Most of the Linux kernel code is written using the GNU extensions of GCC.

Online IDEs

I pioneered online programming with SMX Explorer in 1994, JSP Explorer in 2000, and supported most available languages in 2002 with Zamples.com.

Now it seems that every day another online programming option becomes available. Many are free:

Installing C/C++ on WSL/Ubuntu

Online programming is fine for learning, but I prefer to be independent and self-reliant whenever practical for doing actual work.

Command-Line Toolchain

To program in C or C++ on Ubuntu using the traditional Linux command-line tool­chain, install the build-essential Debian meta-package on Ubuntu. It includes the GNU Compiler Collection (GCC), which is a collection of compilers and libraries for C, C++, Objective-C, Fortran, Ada, Go, and D programming languages. It also includes make and libc6.1-dev, the GNU C development libraries and header files.

You probably should also install gdb, the GNU Project Debugger, and the manual pages about using GNU/Linux for development.

Shell
$ sudo apt install build-essential gdb manpages-dev

Now you are able to compile and run C programs at the command line:

Shell
$ mkdir test && cd test

$ cat >test.c <<EOF
#include <stdio.h>
int main(void) {
  printf("Hello, World!\n");
}
EOF

$ gcc test.c -o test && ./test
Hello, World! 

Visual Studio Code

Visual Studio Code is a high-quality (and free) IDE. To work with C and C++ in Visual Studio Code, install the Microsoft C/C++ extension.



* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.