delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/30/14:44:43

Date: Thu, 30 Nov 1995 17:17:30 +0000 (GMT)
From: Andy Molyneux <molyneua AT cs DOT man DOT ac DOT uk>
To: "Michael E. Wesolowski" <mewesolo AT freenet DOT calgary DOT ab DOT ca>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Declaring arrays inside generic function

On Mon, 27 Nov 1995, Michael E. Wesolowski wrote:

> I have a generic function which has as one of its input parameters an int 
> which identifies an array size. Within the function, I attempt to declare 
> an array of int's:
> 
> int item_count [array_size];
> 
In ANSI C, it's not possible to declare an array of variable size - it 
should be a "constant" expression.  However, one of gcc's extensions to 
ANSI C allows you to do this (if you don't specify the -ansi option).  
That's what I know anyway; hope it helps you with your problem.

- Andy

| Andrew Molyneux            Internet: molyneua AT cs DOT man DOT ac DOT uk
| University of Manchester   Tel     : (+44)161-485-3291
| REAL programmers write  a=b!=4?b%2?c:d:e  without even
| thinking about it :-)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019