dynamic array size in compile time?

I

ir1979

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.
 
P

Peter Nilsson

ir1979 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top