error: non-constant-expression cannot be narrowed from type 'int' to 'SLuint32'

问题:wav_get_rate(wav)返回类型是unit16_t,然后与1000相乘后返回int类型

error: non-constant-expression cannot be narrowed from type 'int' to 'SLuint32'

 

但是需要返回unit32_t类型,然后报了下面的错误

error: non-constant-expression cannot be narrowed from type 'int' to 'SLuint32'

 

原因:返回的类型与所需要的类型不一致

解决办法:

将int类型转为unit类型

error: non-constant-expression cannot be narrowed from type 'int' to 'SLuint32'