#define adr(x) ((word) &(x)) char tmsec[20]; struct par_struct AL[] = { //par.nr, lv, ln, eh, adress bk, pt, ft { 1, 2, 8, 0, 0, ptUSER, 40}, { 2, 2, 8, 0, 0, ptUSER, 41}, { 3, 2, 1, 0, 0, ptUSER, 42}, { 4, 0, 0, 1, adr(Tmsec), };
The ISO C 1999 standard. Chapter 6.7.8 'Initialization', constraints: 4 All the expressions in an initializer for an object that has static storage duration shall be constant expressions or string literals. Chapter 6.6 'Constant expressions', semantics: 7 More latitude is permitted for constant expressions in initializers. Such a constant expression shall be, or evaluate to, one of the following: - an arithmetic constant expression, - a null pointer constant, - an address constant, or - an address constant for an object type plus or minus an integer constant expression. 8 An arithmetic constant expression shall have arithmetic type and shall only have operands that are integer constants, floating constants, enumeration constants, character constants, and sizeof expressions. Cast operators in an arithmetic constant expression shall only convert arithmetic types to arithmetic types, except as part of an operand to a sizeof operator whose result is an integer constant. 9 An address constant is a null pointer, a pointer to an lvalue designating an object of static storage duration, or a pointer to a function designator; it shall be created explicitly using the unary & operator or an integer constant cast to pointer type, or implicitly by the use of an expression of array or function type. The array-subscript [] and member-access . and -> operators, the address & and indirection * unary operators, and pointer casts may be used in the creation of an address constant, but the value of an object shall not be accessed by use of these operators. Actually, after reading it all again I get the impression that addresses of static objects are allowed as initializers, but only as pointers and not as integers. Sorry, my mistake apparently. - mike
You're interpreting the standard better than my memory did, Mike. The address itself would have been eligible for an initializer, but the cast turned it into an implementation-defined thing, which the implementation can rightfully refuse to allow in an initializer. And of course, as soon as keywords like 'near' or 'far' become involved, you're well outside the region where any language standard would apply in the first place.