【问题标题】:ARM Keil error #17 expected a "]", C3910W: Old syntaxARM Keil 错误 #17 应为“]”,C3910W:旧语法
【发布时间】:2015-02-24 16:12:21
【问题描述】:

您好,我正在尝试在 Keil μVision v.5.12 上构建一个程序。

错误似乎只有“一个”(期待])。但是代码工作(编译和运行没有错误/警告)我的 linux 分区。

Rebuild target 'Target 1'
compiling ax.c...
ax.c: Warning: C3910W: Old syntax, please use '--c99'.
23_2\fixvector3d.h(30): warning:  #1-D: last line of file ends without a newline
  #endif
23_2\fixquat.h(73): warning:  #1-D: last line of file ends without a newline
  #endif
23_2\fixstring.h(21): warning:  #1-D: last line of file ends without a newline
  #endif
23_2\ax.c(46): error:  #17: expected a "]"
        mf16 Adew =  {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(47): error:  #17: expected a "]"
                     {[0 ... DIM-    1] = fix16_from_int(0)},            
23_2\ax.c(48): error:  #17: expected a "]"
                     {[0 ... DIM-    1] = fix16_from_int(0)}}};
23_2\ax.c(58): error:  #17: expected a "]"
        mf16 sqrtD = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(59): error:  #17: expected a "]"
                     {[0 ... DIM-    1] = fix16_from_int(0)},            
23_2\ax.c(60): error:  #17: expected a "]"
                     {[0 ... DIM-    1] = fix16_from_int(0)}}};
23_2\ax.c(64): error:  #17: expected a "]"
        mf16 transE = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(65): error:  #17: expected a "]"
                       {[0 ... DIM-    1] = fix16_from_int(0)},
23_2\ax.c(66): error:  #17: expected a "]"
                       {[0 ... DIM-    1] = fix16_from_int(0)}}};
23_2\ax.c(70): error:  #17: expected a "]"
        mf16 inv_eigenvectors = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(71): error:  #17: expected a "]"
                         {[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(72): error:  #17: expected a "]"
                        {[0 ... DIM-1] = fix16_from_int(0)}}};
23_2\ax.c(76): error:  #17: expected a "]"
        mf16 eigenvectors = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(77): error:  #17: expected a "]"
                     {[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(78): error:  #17: expected a "]"
                       {[0 ... DIM-1] = fix16_from_int(0)}}};
23_2\ax.c(82): error:  #17: expected a "]"
        mf16 whiteningMatrix = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(83): error:  #17: expected a "]"
                       {[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(84): error:  #17: expected a "]"
                   {[0 ... DIM-1] = fix16_from_int(0)}}};
23_2\ax.c(88): error:  #17: expected a "]"
        mf16 dewhiteningMatrix = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(89): error:  #17: expected a "]"
                       {[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(90): error:  #17: expected a "]"
                      {[0 ... DIM-1] = fix16_from_int(0)}}};
23_2\ax.c(94): error:  #17: expected a "]"
        mf16 Bold = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(95): error:  #17: expected a "]"
                      {[0 ... DIM-    1] = fix16_from_int(0)},
23_2\ax.c(96): error:  #17: expected a "]"
                       {[0 ... DIM-    1] = fix16_from_int(0)}}};
23_2\ax.c(100): error:  #17: expected a "]"
        mf16 tempMatrixOne = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(101): error:  #17: expected a "]"
                           {[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(102): error:  #17: expected a "]"
                   {[0 ... DIM-1] = fix16_from_int(0)}}};
23_2\ax.c(106): error:  #17: expected a "]"
        mf16 tempMatrixTwo = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(107): error:  #17: expected a "]"
                         {[0 ... DIM-1] = fix16_from_int(0)},
23_2\ax.c(108): error:  #17: expected a "]"
                   {[0 ... DIM-1] = fix16_from_int(0)}}};
assembling startup_ARMCM0.s...
compiling system_ARMCM0.c...
system_ARMCM0.c: Warning: C3910W: Old syntax, please use '--c99'.
".\Objects\ax.axf" - 30 Error(s), 5 Warning(s).

** 我的代码中出现错误的部分

mf16 Adew =  {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)},        
                            {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_Adew;     
ptr_Adew = &Adew;

mf16 identity = {DIM, DIM, 0, {{fix16_from_int(1),fix16_from_int(0),fix16_from_int(0)},
                               {fix16_from_int(0),fix16_from_int(1),fix16_from_int(0)},
                               {fix16_from_int(0),fix16_from_int(0),fix16_from_int(1)}}};
mf16 *ptr_identity;     
ptr_identity = &identity;

mf16 sqrtD = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)},        
                            {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_sqrtD;        
ptr_sqrtD = &sqrtD;

mf16 transE = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_transE;
ptr_transE = &transE;

mf16 inv_eigenvectors = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                                       {[0 ... DIM-1] = fix16_from_int(0)},
                                       {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_inv_eigenvectors;         
ptr_inv_eigenvectors = &inv_eigenvectors;   

mf16 eigenvectors = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                                   {[0 ... DIM-1] = fix16_from_int(0)},
                                   {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_eigenvectors;                             
ptr_eigenvectors = &eigenvectors;                           

mf16 whiteningMatrix = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                                      {[0 ... DIM-1] = fix16_from_int(0)},
                                      {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_whiteningMatrix;
ptr_whiteningMatrix = &whiteningMatrix;

mf16 dewhiteningMatrix = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                                        {[0 ... DIM-1] = fix16_from_int(0)},
                                        {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_dewhiteningMatrix;
ptr_dewhiteningMatrix = &dewhiteningMatrix;

mf16 Bold = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_Bold;
ptr_Bold = &Bold;

mf16 tempMatrixOne = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                                    {[0 ... DIM-1] = fix16_from_int(0)},
                                    {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_tempMatrixOne;
ptr_tempMatrixOne = &tempMatrixOne;

mf16 tempMatrixTwo = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                                    {[0 ... DIM-1] = fix16_from_int(0)},
                                    {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_tempMatrixTwo;
ptr_tempMatrixTwo = &tempMatrixTwo;

mf16 Btranspose = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                                {[0 ... DIM-1] = fix16_from_int(0)},
                                {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_Btranspose;
ptr_Btranspose = &Btranspose;

mf16 Bnew = {DIM, DIM, 0, {{[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)},
                            {[0 ... DIM-1] = fix16_from_int(0)}}};
mf16 *ptr_Bnew;
ptr_Bnew = &Bnew;

我做错什么了? (我是否忘记了设置我的 keil 项目的任何内容?,也许是 .h?还是 [0 ... 维度] 声明了我的矩阵?)

【问题讨论】:

  • [0 ... 9] 等范围是 GCC 扩展,因此其他编译器可能不支持。
  • @interjay 是的!很简单,或者我可以说我懒得尝试更改我的代码......谢谢!现在我有链接问题....我如何将您的答案指出为...正确答案?还是我应该回答我的问题?
  • 看起来 ouah 发布了答案,所以您可以接受他的答案。

标签: c compiler-errors arm microcontroller keil


【解决方案1】:

正如interjay 将它放在 cmets 中一样,您使用的是特定于 gcc 的 C 扩展,并且在 Keil 上不兼容。

来自gccdocumentation

要将一系列元素初始化为相同的值,请编写“[first ... last] = value”。这是一个 GNU 扩展。例如,

int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };

【讨论】:

  • 你知道如何以及我是否可以准确地看到编译文件中的错误:`警告:C3910W:旧语法,请使用'--c99'。 ` 生成?
  • @Franx 我修复了链接。
  • @Franx 关于--c99 警告,我可以在您粘贴的代码中看到您正在混合声明和语句(在您的情况下为赋值语句):c90 中不允许,并且仅允许自c99.
猜你喜欢
  • 2014-06-28
  • 1970-01-01
  • 1970-01-01
  • 2012-07-06
  • 2018-04-23
  • 1970-01-01
  • 2018-09-03
  • 2018-12-29
  • 2022-01-25
相关资源
最近更新 更多