错误C2057:vs2008中的预期常量表达式

时间:2015-10-15 09:28:46

标签: c

static const unsigned int x[] = { 1, 2, 3, 5 };  
static const int q = sizeof(x) **/** sizeof(x[0]);  

size_t fun(int n, int m)  
{  
    unsigned int p[q];  
}

如何解决此错误?这是一个c代码。

1 个答案:

答案 0 :(得分:0)

这是**/** sizeof(x[0]);是什么,这不是如何发表评论,也不要忘记在表达结尾处加分号。

static const unsigned int x[] = { 1, 2, 3, 5 };  

static const int q = sizeof(x)/sizeof(x[0]); /* sizeof(x[0]); */

size_t fun(int n, int m)  
{  
    unsigned int p[q];  
}

int main()
{
}