How are C data types “supported directly by most computers”?

Yes, there are data types not directly supported.

On many embedded systems, there is no hardware floating point unit. So, when you write code like this:

float x = 1.0f, y = 2.0f;
return x + y;

It gets translated into something like this:

unsigned x = 0x3f800000, y = 0x40000000;
return _float_add(x, y);

Then the compiler or standard library has to supply an implementation of _float_add(), which takes up memory on your embedded system. If you’re counting bytes on a really tiny system, this can add up.

Another common example is 64-bit integers (long long in the C standard since 1999), which are not directly supported by 32-bit systems. Old SPARC systems didn’t support integer multiplication, so multiplication had to be supplied by the runtime. There are other examples.

Other languages

By comparison, other languages have more complicated primitives.

For example, a Lisp symbol requires a lot of runtime support, just like tables in Lua, strings in Python, arrays in Fortran, et cetera. The equivalent types in C are usually either not part of the standard library at all (no standard symbols or tables) or they are much simpler and don’t require much runtime support (arrays in C are basically just pointers, nul-terminated strings are almost as simple).

Control structures

A notable control structure missing from C is exception handling. Nonlocal exit is limited to setjmp() and longjmp(), which just save and restore certain parts of processor state. By comparison, the C++ runtime has to walk the stack and call destructors and exception handlers.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)