Forward declarations in function prototypes, yet again
Bruce Blodgett
uunet!apollo.hp.com!blodgett
Fri Jul 17 10:31:31 PDT 1992
Peter S. Shenkin writes:
> It sure as hell is going to be easier for ANY programmer to remember what
> the following declaration means:
>
> function( float a[n], int n );
>
> than it will be for him to remember any syntax yet proposed that preserves
> the precious "declare before use" rule.
Just so that I understand this proposal, does the "n" in "float a[n]"
parse as an expression, where the expression may still be constant (as
before), or may now additionally refer to other formal parameters but
nothing else (e.g., no global variables)? In each of these examples,
the trailing comment indicates my understanding of the dimension of
array a:
{ int f1( int a[3], int n ); /* array a is obviously an array of 3 ints */ }
{ int n; int f1( int a[n], int n ); /* use formal parameter n? */ }
{ const int n = 3; int f1( int a[n], int n ); /* use formal parameter n? */ }
{ enum { n = 3 }; int f1( int a[n], int n ); /* use formal parameter n? */ }
{ enum { n = 3 }; int f1( int a[n], int j ); /* use enum value of 3? */ }
{ enum { n = 3 }; int f2( int n, int a[n] ); /* use formal parameter n? */ }
Bruce Blodgett
blodgettaapollo.hp.com
(508) 436-4037
More information about the Numeric-interest
mailing list