This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 编译器/TMS320F2.8377万D:"非法使用固有函数:__f32toi16r"和"非法使用固有函数:__f32toi16r" on符号不匹配变量赋值

Guru**** 2589280 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/614636/compiler-tms320f28377d-illegal-use-of-intrinsic-__f32toi16r-and-illegal-use-of-intrinsic-__f32toui16r-on-sign-mismatch-of-variable-assignment

部件号:TMS320F2.8377万D

工具/软件:TI C/C++编译器

代码片段:

void test_signed_unsigned_type_mismatch (const double * restrict F32,unsigned int * restrict i16,int num)

   对于(; num >0; num --)
   {
       *i16++=__f32toi16r (*F32++);
   }
}

使用以下命令编译:

c:\ti/ccsv6/tools/compiler/ti-CGT-2000_LTS/bin/cl2000"<xmt-block0>2000 16.9 -v28 -ml -mt --CLA_support=cla1 --float_support=fpu32 --tmu_support=tvm=tmu0 --vcu_support=vcu2 -o4 --opt_for rag_fundiag_s=fuel_proc -fuel_s_ p_p_lists=t_ip_fuel_fu=t_model=-fu_ip_ip_fuel_intran_f_fuel_model=-f_intran=-fg_ip_model_ip_f_model_ip_f_f_fcpuenci=-fcpuan_f_f_fcpu_f_fcpuenci=-fcpuenci=-f_line_compass_line_listc=-fcpuencu_linu_fcpu_linu_ps=-fcpu_ps=-fcc 16.9

给出错误:

错误#9.9923万:"../f32toi16r.c",第5行:非法使用内在:__f32toi16r.

代码片段:

void test_signed_unsigned_type_mismatch (const double * restrict F32,int * restrict i16,int num)

   对于(; num >0; num --)
   {
       *i16++=__f32oui16r (*F32++);
   }
}

 

使用以下命令编译:

c:\ti/ccsv6/tools/compiler/ti-CGT-2000_LTS/bin/cl2000"<xmt-block0>2000 16.9 -v28 -ml -mt --CLA_support=cla1 --float_support=fpu32 --tmu_support=tvm=tmu0 --vcu_support=vcu2 -o4 --opt_for rag_fundiag_s=fuel_proc -fuel_s_ p_p_lists=t_ip_fuel_fu=t_model=-fu_ip_ip_fuel_intran_f_fuel_model=-f_intran=-fg_ip_model_ip_f_model_ip_f_f_fcpuenci=-fcpuan_f_f_fcpu_f_fcpuenci=-fcpuenci=-f_line_compass_line_listc=-fcpuencu_linu_fcpu_linu_ps=-fcpu_ps=-fcc 16.9

给出错误:

错误#9.9923万:"../f32toi16r.c",第5行:非法使用内在:__f32toi16r.

代码片段:

void test_no_sign_mismatch (const double * restrict F32,unsigned int * restrict i16,int num)

   对于(; num >0; num --)
   {
       *i16++=__f32oui16r (*F32++);
   }
}

和:

void test_no_sign_mismatch (const double * restrict F32,int * restrict i16,int num)

   对于(; num >0; num --)
   {
       *i16++=__f32toi16r (*F32++);
   }
}

成功编译。  

对于符号到符号,结果在C标准中指定为结果模数6.5536万。 对于unsigned to signed,如果number unsigned number在signed范围内,则定义unsigned to signed;如果unsigned number超出整数范围,则定义实现。

为什么返回类型和赋值类型不匹配会导致编译器错误?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我认为,这不应造成错误。  我认为这是一个错误,并提交了CodeGen-3580来跟踪此问题。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    顺便提一下 ,2013年初发布的文章e2e.ti.com/.../重定向。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我不认为这些是同样的问题。 在这两种情况下,内部函数的值都分配给具有相同符号的类型。 CodeGen-3580要求将内在过程的值分配给带有相反符号的类型。