LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Why doesn't const int work?

The piece of code below should compile.  It does not.  Looking at several C++ books it claims that is shoud.
Any ideas.  Thanks.
 
the old vax guy.....
 

const int stack_size = 45;
double   stack[stack_size];
void main(void)
{
stack[0]=0;
}
 
0 Kudos
Message 1 of 3
(2,915 Views)
LabWindows/CVI is strictly based on ANSI-C and although C++ might allow a variable to be used in array initialization, ANSI-C does not permit this.

If you want to declare an array in C, you need to use a constant expression (an actual number or a #define constant defined to a number).

Ludek
NI
0 Kudos
Message 2 of 3
(2,906 Views)

Ipekarek.

Thanks for the answer.   NI also answered with the fact that CVI follows the 89 ansi-c standard not the 99 ansi-c standard. 

Also, I'm using #defines.

Thanks again. 

the old vax guy.

  

0 Kudos
Message 3 of 3
(2,880 Views)