Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > dynamic array size in compile time?

Reply
Thread Tools

dynamic array size in compile time?

 
 
ir1979
Guest
Posts: n/a
 
      05-04-2009
Hi there,

I want to declare an array whose size can be calculated in compile
time. But I as a busy programmer (!) want the compiler to do so. For
example in the following code:

#define N 20 //max number of nodes
#define M 10 //max number of alphabets

int main()
{
const long p2n = pow(2,N)-1;
char f [p2n][p2n][M+1]={0};
}


,how can I say the compiler that p2n is a constant that can be
evaluated in compile time (that's like a simple constant).

Thanks.
 
Reply With Quote
 
 
 
 
Peter Nilsson
Guest
Posts: n/a
 
      05-04-2009
ir1979 <ir1...@gmail.com> wrote:
> Hi there,
>
> I want to declare an array whose size can be calculated
> in compile time. But I as a busy programmer (!) want the
> compiler to do so. For example in the following code:
>
> #define N 20 * *//max number of nodes
> #define M 10 * *//max number of alphabets
>
> int main()
> {
> * * const long p2n = pow(2,N)-1;
> * * char f [p2n][p2n][M+1]={0};


Use (1ul << expr).

> }
>
> ,how can I say the compiler that p2n is a constant
> that can be evaluated in compile time (that's like
> a simple constant).


The harder problem is finding an implementation that
supports 10+ terabytes of automatic storage.

--
Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Choose to use compile time or dynamic run time for big array. Immortal Nephi C++ 3 12-23-2009 12:54 PM
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Dynamic Size for Text Box - Expanding more than the relative size Madhanmohan S ASP .Net 5 09-03-2004 06:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57