For Loop Error "error: expected identifier or '(' before '[' token"

This is a discussion on For Loop Error "error: expected identifier or '(' before '[' token" within the C Programming forums, part of the General Programming Boards category; I am receiving this error various times ..\src\using-gpib_dll.c:97:18: error: expected identifier or '(' before '[' token The problem appears to ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    10

    Question For Loop Error "error: expected identifier or '(' before '[' token"

    I am receiving this error various times
    ..\src\using-gpib_dll.c:97:18: error: expected identifier or '(' before '[' token
    The problem appears to reside inside my for loop:

    Code:
    for (loop = 0; loop < 30; loop++)
       {
          Instruments[loop] = (Addr4882_t)(loop + 1);
       }
    For some reason, 'Instruments[loop]' is not being detected as the declared array (see attached code). Did I declare it wrong?

    Thank you for any help.
    Attached Images Attached Images  
    Attached Files Attached Files

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    We do not declare arrays with typedef.Actually nothing is been declared with typedef.typedef gives you a synonimous for the other word.
    A declaration of an array looks like this
    Code:
    int instruments[31];

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,501
    I think that you have a problem with how the variable is being declared

    look at typedef tutorial

  4. #4
    Registered User
    Join Date
    Aug 2012
    Posts
    10
    Quote Originally Posted by std10093 View Post
    We do not declare arrays with typedef.Actually nothing is been declared with typedef.typedef gives you a synonimous for the other word.
    A declaration of an array looks like this
    Code:
    int instruments[31];
    This did the trick, thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 08-09-2012, 01:48 PM
  2. Error: expected identifier or ( before { token
    By jpcanaverde in forum C Programming
    Replies: 66
    Last Post: 06-08-2010, 01:53 PM
  3. Replies: 9
    Last Post: 03-31-2009, 05:23 PM
  4. Replies: 7
    Last Post: 09-14-2008, 09:37 AM
  5. [HELP]Winsock Error "syntax error before ';' token"
    By C-isCool in forum C Programming
    Replies: 2
    Last Post: 07-05-2007, 08:32 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21