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

  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 For Loop Error &quot;error: expected identifier or '(' before '[' token&quot;-unexpected_identifier-png 
    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,907
    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, 12:48 PM
  2. Error: expected identifier or ‘(’ before ‘{’ token
    By jpcanaverde in forum C Programming
    Replies: 66
    Last Post: 06-08-2010, 12:53 PM
  3. Replies: 9
    Last Post: 03-31-2009, 04:23 PM
  4. Replies: 7
    Last Post: 09-14-2008, 08:37 AM
  5. [HELP]Winsock Error "syntax error before ';' token"
    By C-isCool in forum C Programming
    Replies: 2
    Last Post: 07-05-2007, 07:32 PM

Tags for this Thread