Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Generic programming in C

Name: Anonymous 2012-01-12 3:49

I love C so much, and I really want to hate sepples, but I can't help but think that generic programming in C is shit! Macros are no good for generic data structures, as they are clunky and blow out code size, nor are void pointers, as you need to allocate separate memory just to store an integer (don't stuff ints into pointers; zeros won't work on architectures where the null pointer constant is non-zero). I really want to write my data structure library in sepples, where templates allow type genericism without issue. What should I do, /prague/; what should I do?!

Name: Anonymous 2012-01-12 14:35

>>3,40,46
The C standard does not describe or mention a "stack." In many implementations, the activation record, arguments, and local variables are stored in different regions of memory or registers. The System/360 (S/370, S/390, and System z) uses a linked list of activation records allocated using GETMAIN and separate memory regions for the argument list and local variables, also allocated using GETMAIN. Similarly, the ARM allows "chunked stacks" where each activation record is part of a linked list. The VAX uses a contiguous stack for return addresses, but also has CALLG which is a standard call where the argument list can be anywhere in memory. Many RISCs pass arguments in registers and store the return address in a register, so they are able to complete a function call without even touching a stack. Other machines may use separate stacks for return addresses, arguments, and local variables, and may further break them down depending on whether these items are integers, floating-point, or pointers. Some small architectures like PICs may use static variables for all functions that are determined at compile time not to be recursive, allowing the fixed-size stack to be conserved for storing return addresses without violating the standard.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List