Thread: Label cannot attach to a declaration

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    144

    Label cannot attach to a declaration

    Hi everyone. When I compile the following code using gcc -Wall -Wextra, GCC tells me : "error: a label can only be part of a statement and a declaration is not a statement" for the line after case 2:. I got it to compile by inserting a null statement (ie a semicolon) after the colon in case 2:. Is this correct C99?

    Code:
    switch (variable)
    {
    case 1:
       blah ;
    case 2:
    char *myptr = strstr (str1 , str2);
    ...
    }
    Last edited by Richardcavell; 03-20-2011 at 12:50 AM. Reason: clarity

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 08-16-2010, 10:00 AM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

Tags for this Thread