ZHCUBL2K January 2018 – March 2024
从 C7000 编译器 v3.0 开始,C7000 TI 编译器 (cl7x) 接受构造函数样式的语法来进行向量初始化。若要创建使用 cl7x 和主机仿真进行编译的可移植代码,请对向量初始化使用构造函数样式语法,而不是仅适用于 cl7x 的“cast/scalar-widening”初始化样式。
以下代码中显示了正确和错误的向量构造函数初始化语法示例。
/* Host Emulation vector constructor syntax examples */
// The following examples work for both cl7x and Host Emulation
long2 ex1 = long2(1); // -> (1,1)
long2 ex2 = long2(1,2); // -> (1,2)
long8 ex3 = long8(long4(1), long4(2)); // -> (1,1,1,1,2,2,2,2)
long8 ex4 = long8(long4(1),2,3,4,5); // -> (1,1,1,1,2,3,4,5)
// Do not use the following syntax for code that needs to compile
// with Host Emulation. This is valid C++ syntax, but results are
// not as expected when compiling with Host Emulation.
//long8 ex5 = (long8)(1,2,3,4,5,6,7,8); // -> (8,8,8,8,8,8,8,8) [for Host Emulation]