Request for following excerpt's explanation.

http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/param_decl.htm

Except in certain contexts, an unsubscripted array name (for example, region instead of region[4]) represents a pointer whose value is the address of the first element of the array, provided that the array has previously been declared. An array type in the parameter list of a function is also converted to the corresponding pointer type. Information about the size of the argument array is lost when the array is accessed from within the function body.

To preserve this information, which is useful for optimization, you may declare the index of the argument array using the static keyword. The constant expression specifies the minimum pointer size that can be used as an assumption for optimizations. This particular usage of the static keyword is highly prescribed. The keyword may only appear in the outermost array type derivation and only in function parameter declarations. If the caller of the function does not abide by these restrictions, the behavior is undefined.

The following examples show how the feature can be used.

void foo(int arr [static 10]);       /* arr points to the first of at least
                                           10 ints                           */
void foo(int arr [const 10]);        /* arr is a const pointer               */
void foo(int arr [static const i]);  /* arr points to at least i ints;
                                           i is computed at run time.        */
void foo(int arr [const static i]);  /* alternate syntax to previous example */
void foo(int arr [const]);           /* const pointer to int                 */

That may be some compiler-specific extensions to the c++ standards. None of the compilers I know about allow that kind of constructs.

I second Ancient Dragon's comment. I am surprised that IBM's documentation does not say that it's use is non portable for the C language.

Frankly I would not recommend you use that syntax unless you know for sure you will never port your programs to other platforms.

Alright and thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.