Article View: gnu.gcc.bug
Article #1849difficulties with dynamic arrays in gcc
From: Matthew Self
Date: Mon, 24 Oct 1988 23:42
Date: Mon, 24 Oct 1988 23:42
37 lines
1428 bytes
1428 bytes
With gcc, there is a problem passing a dynamic array to a function
when the size of the array is also an argument to the function. The
problem is that the size argument must appear BEFORE the array in the
prototype argument list. For exmaple, the function
void test(float a[][n], int n) {}
will not compile, but the function
void test(int n, float a[][n]) {}
will. The workaround is obvious, but it is cumbersome to force
programmers to re-order the arguments of their functions. Since the
prototype is purely a declaration, it would seem reasonable to permit
the necessary forward reference.
Using conventional function declarations, the function
void test(a, n)
float a[][n];
int n;
{}
will not compile, but the function
void test(a, n)
int n;
float a[][n];
{}
will. In this case the arguments can be left in the same order---only
the type declarations need be rearranged.
Matthew Self
NASA Ames Research Center
self@bayes.arc.nasa.gov
Technical Details
Message-ID:
<8810242342.AA00585@bayes.arc.nasa.gov>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!bu-cs!bloom-beacon!tut.cis.ohio-state.edu!BAYES.ARC.NASA.GOV!selfShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!bu-cs!bloom-beacon!tut.cis.ohio-state.edu!BAYES.ARC.NASA.GOV!self From: self@BAYES.ARC.NASA.GOV (Matthew Self) Newsgroups: gnu.gcc.bug Subject: difficulties with dynamic arrays in gcc Message-ID: <8810242342.AA00585@bayes.arc.nasa.gov> Date: 24 Oct 88 23:42:18 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 37