variably modified 'dist' at file scope|

时间:2022-02-08 19:23:15

转自:http://blog.csdn.net/wusuopubupt/article/details/18408227

错误原因:

The reason for this warning is that const in c doesn't mean constant. It means "read only". So the value is stored at a memory address and could potentially be changed by machine code.

在c里静态数组(固定长度的数组,即LISTEN_NUM位置是常数)是允许的,而动态数组(譬如给数组的长度是用变量来表示的)不能写成 UserProfile users[LISTEN_NUM];形式的,只能自行分配内存。