2015-02-24 690 views
0

嗨我想在KeilμVisionv.5.12上建立一个程序。ARM Keil错误#17期望一个“]”,C3910W:旧的语法

错误似乎只是“一”(期待])。但代码的作品(编译和运行没有错误/警告)on我的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; 

enter image description here 我做了什么错? (我是否伪造了任何设置我的keil项目的东西,或许是.h?或者是[0 ... dimension]声明了我的矩阵?)

+1

范围等'[0 ... 9]'是一个GCC延伸,所以可以不在其他的编译器支持。 – interjay 2015-02-24 16:18:29

+0

@interjay是的!很简单,或者我可以说我很懒,试图改变我的代码......谢谢! 现在我有链接问题.... 我如何指出你的答案是......正确答案?或者我应该回答我的问题? – Franx 2015-02-24 16:45:19

+0

ouah看起来像一个答案,所以你可以接受他的答案。 – interjay 2015-02-24 17:05:59

回答

1

As interjay将它置于注释中,您使用的是C扩展具体到gcc和Keil不兼容。

gccdocumentation

To initialize a range of elements to the same value, write ‘[first ... last] = value’. This is a GNU extension. For example,

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

你知道如何以及如果我能确切地看到编译文件中的错误:'警告:C3910W:旧语法,请使用'--c99'。 '生成? – Franx 2015-02-24 17:19:23

+0

@ouach哦,你的文档链接不工作! – Franx 2015-02-24 17:30:11

+0

@Franx我修复了链接。 – ouah 2015-02-24 20:00:33

相关问题