4.3 Variable Declaration

All variables should be declared at the beginning of a block (for compatibility with old compilers), even though all supported compilers support the C11 standard and allow variables to be declared anywhere in a block, including after executable code.

Instance variables in public APIs should generally be limited to those which are explicitly declared to be public and which will never change (we want to avoid breaking ABI between releases by changing instance variable layouts).

The standard mechanism to support this is to provide a single private pointer variable (void *_internal;) which will be used to point to an area of memory containing the actual instance variables used internally. The internal implementation is then free to change without any change to the size of instances of the class.

The GNUstep-base library has a standardised set of macros for writing code which deals with use of an _internal pointer to instance variables at the same time as allowing the instance variables to be used directly in the class if the code is built using the non-fragile ABI.