![](/ext.png)
Background Information edit
- History and Spirit of C and C++ (pdf)
, by Olve Maudal
Critique edit
Documentation edit
- C99 Draft (N869)
- at busybox.net
- C99 draft specification
- big HTML file
- Draft ANSI C: Standard (ANSI X3J11/88-090)
, C Rationale (ANSI X3J11/88-151)
- Draft C99 (N1256)
- Draft C1X (N1570)
- The C Programming Language [1], by Brian W. Kernighan and Dennis Ritchie
- The Development of the C Language*
, Dennis M. Ritchie
- C FAQ
- Programming in C
- a list of various C papers and resources
Description edit
The ANSI committee as well as the ISO committee have approved a standard reference for C.Support for C is traditionally provided by a compiler. Some efforst at a C interpreter also exist.Most Unix systems provide vendor-supported compilers. They are often unbundled products these days.Dialects edit
Free Compilers edit
- gcc, by the FSF
- a quite popular C compiler found on many platforms and operating systems. Apple XCode provides a gcc distribution for Mac OS X.
- [clang]
- C language family frontend for LLVM [2]
- Cygwin
- C compiler (free; a version of gcc; for some strange reason it cannot be used to compile the Tcl source code out-of-the-box - but Cygwin comes with its own version of Tcl at least),
- Mingw
- C compiler [3] (free; another version of gcc for Windows with goals slightly different from Cygwin),
- OpenWatcom C/C++ compiler
- Free. Microsoft Windows, OS/2, DOS, and Linux.
- tcc
- the "Tiny C Compiler". Free.
- The SubC Compiler
, by Nils M Holm
- Free. A fast and simple public domain compiler for a clean subset of the C programming language. It can compile itself and passes gcc -Wall -pedantic. Companion to Practical Compiler Construction: A Non-nonsense Tour Through a C Compiler
.
Proprietary Compilers edit
- C++Builder
- Commercial. An older command-line version is still available as a free download
- freescale CodeWarrior
- Commercial. Previously by Metrowerks. Versions for Windows and MacOS Classic and MacOS X previously existed.
- Digital Mars C and C++
- Commercial. No charge. Was once Zortech C and later became Symantec C
- IBM XL C and C++
- Commercial. For AIX, IBM i, Blue Gene, Linux, z/VM, Z/OS
- Intel C++ compiler
- Commercial:
- LCC-Win32
- Commercial. No charge for non-commercial use.
- Microsoft Visual C++
- Commercial. Now only avaialable as a component of Visual Studio.
- Microsoft Visual Studio
- Commercial. Visual Studio Express at no charge. For Microsoft Windows.
Historical edit
- Macintosh Programmer's Workshop
: for MacOS Classic
- Abandonware
Interpreters edit
- CInt
- RFox: a (free) interpreter, originally from Masaharu Goto, and apparently currently maintained by the CERN Root team which uses CInt as its scripting language. I do not know if Tcl can be interpreted under this interpreter
- Ch
- a C/C++ interpreter that runs cross-platform on a large number of operating systems and hardware. It provides not only standard language features, but also support for 2 and 3 dimensional plotting, shell programming, and numerical programming. It supports 1990 ISO C standard as well as C99 features. In Jan, 2003, the product page for Ch Standard says that the product is free for use on Unix, Linux, and Mac OS X.
- EiC
- another C interpreter.
Linkable Compilers edit
Support for C can also take the form of a run-time compiler.tcc provides a libtcc library, which allows a running program to compile and link C code without touching disk. In milliseconds for a small chunk of code. (x86 only as of Jun 2003)OdyceC Annoyances edit
AMG: One annoying thing about C is that, like Fortran, it uses = as its assignment operator. This is very easy to confuse with the comparison operator ==, resulting in either of the following two coding errors:x == 5; /* Nothing happens, except maybe a warning if -Wall is on. */ if (x = 6) {...} /* Unintended assignment and incorrect logic. */Algol uses := as its assignment operator, and C is ancestrally derived from Algol, so I was always mystified about why C reverted to Fortran's assignment syntax. But I just now figured it out, I think. A := assignment operator looks almost identical to C's != inequality operator, so using := instead of = for assignment simply trades one potential coding error for another. To fix that problem, != would have to be replaced with, say, /= (borrowed from Ada), but that (1) collides with the compound division and assignment operator /= and (2) breaks symmetry with the logical negation operator !. Or instead use \=, but that will behave unexpectedly when placed inside double quotes. Or use <> and be like BASIC and SQL. Shrug![name redacted]: the change from := to = was made during the transition from BCPL to B (and simply kept when going from B to C), and IIRC the reason was that Ken Thompson felt that an operator that was going to be used as often as assignment was should be as short as possible. The reasons you mention may of course also have affected his decision, but there was never any secondary ambiguity with "divide-assign", which was written as =/ in B.Larry Smith Frankly, in this day and age, assignment should be "←". We need to start using unicode for programs and frankly, it's past time to worry about the kind nonsense we have had to put with in ascii's limitations. Ascii is so 20th century. Swap should be ↔,less than, <, greater, >, equal, =, multiply and divide, × and ÷ and lessthan or equal and greater or equal should be ≤ and ≥. APL, essentially the only programming languages to get this, was right. J is, in fact, something of a step backward at the very moment in time when APL's disadvantages are now fewer in number and less in nature. In fact, we could do a lot of this for "nearly" free by just bolting in an APL interpreter in place of the expression evaluator (or, more likely, as an alternative for some time). We could use http://www.nars2000.org/
![](/ext.png)
![](/ext.png)
![](/ext.png)
![](/ext.png)
x == y; | warning: statement with no effect |
if (x = y) {...} | warning: suggest parentheses around assignment used as truth value |
if ((ret = read(fd, buf, max)) == -1) { perror("read"); } else { printf("read %d bytes\n", ret); }This style is also available in Tcl:
proc getline {} {...} while {[set line [getline]] ne ""} { puts "got header line: $line" } puts "got blank line, the header is now done"As you can see, Tcl makes it impossible to mix up assignment and comparison. ;^)
PYK 2015-07-30: Undefined behaviour, in combination with optimizing compilers, leads to unpleasant surprises. Here is one from the Linux kernel, as described by A Guide to Undefined Behaviour in C and C++, Part1
![](/ext.png)
static void __devexit agnx_pci_remove (struct pci_dev *pdev) { struct ieee80211_hw *dev = pci_get_drvdata(pdev); struct agnx_priv *priv = dev->priv; if (!dev) return; ... do stuff using dev ... }The error is that since the behaviour of dev->priv is undefined if dev is NULL, a compiler might decide to omit the following check for NULL, leading the program to do stuff using dev when dev is NULL, and even though there is an explicit check in the code for the case that dev is NULL. Apparently this is exactly what some versions of gcc do.
Questions about C vs Tcl edit
How does performance in Tcl compare to comperable programs in C?For instance, certainly there are types of programs which can likely be developed more quickly in Tcl than in C.Are there types of things that run faster in Tcl than C? If not, how much slower than C is Tcl? 10 times slower? 50 times slower? 100 times slower?Miscellaneous Thoughts edit
AMG: I just thought of a cute alternate name for C: "lightspeed". You know, 'cuz physicists use the constant "c" to represent the speed of light. :^) I leave it up to you to figure out if this name has any deeper meaning. At least it would give C an excuse to have a snazzy, energetic theme song![](/ext.png)
Tools edit
- Makeheaders
, DRH
- a simple utility that will automatically generate all the .h files based on the .c or .cpp source files for a large programming project. Hypnotoad also maintains a fork
.
- Parsing C
- a project to create a C parser in Tcl
- Parsing C Types
- an offshot of Parsing C, finds and describes global variables and types
See Also edit
- Cameron Laird's personal notes on how to use C with Tcl
- What 'embedding' means
- How to embed Tcl in C applications
- Adding Tcl/Tk to a C application
- Extending Tcl
- Writing Tcl-Based Applications in C
- Building a custom tclsh
- Tcl_Init
- Tcl C API
- the C interface to Tcl
- Tk C API
- the C interface to Tk
- Init Scripts in the DLL
- Tcl interpreter in C# Application
- Adding Tk to an Existing Xt Program
- Mixing Tcl/Tk and Xt Event Loops
- Using Xlib With Tcl/Tk
- 3D Text for Tk in Unix
- C compiled image processing on an interactive Bwise canvas
- automatically generating socket based Tcl / C connection code, 1
- automatically generating socket based Tcl / C connection code, 2, using bwise
- Connecting Tcl/Tk with GNUstep Objective-C programs
- Building Tcl with the free VC++ toolkit
- How to invoke a C function from Tcl
- Tcl and other languages
- Critcl
- C-header Parser
- a simple parser for C header files
- C code generators
- C Language