...
Code Block | ||||
---|---|---|---|---|
| ||||
void *malloc_custom(size_t nbytes) { void *ptr; /* ... */ /* allocate storage from own pool and set ptr */ return ptr; } void free_custom(void *ptr) { /* ... */ /* return storage to own pool */ } |
Exceptions
DCL37-EX0: It is permissible to use reserved words in declarations when the risk of clashing with a preexisting variable is greater than the risk of clashing with a reserved word. In particular, the scope must be used in a macro that may be invoked with arbitrary preexisting variables (possibly as arguments). The following code demonstrates a SWAP_UNSAFE()
macro that exchanges two values, and uses a __tmp
variable as a temporary value. This code is permitted because the temporary variable is more likely to clash with a non-reserved variable in the current scope than with a reserved word. This code should be considered non-portable; as it requires the current platform to allow the use of __tmp
.
Code Block | ||||
---|---|---|---|---|
| ||||
#define SWAP_UNSAFE(type, a, b) {type __tmp = a; a = b; b = __tmp;}
|
Such macros should only be used with great care. See rules PRE31-C. Avoid side-effects in arguments to unsafe macros and PRE00-C. Prefer inline or static functions to function-like macros for more information.
Risk Assessment
Using reserved identifiers can lead to incorrect program operation.
...