funny error

This is a discussion on funny error within the C++ Programming forums, part of the General Programming Boards category; I have a code using switch function and it gives the following error supersonic_ob.cc:177: error: jump to case label supersonic_ob.cc:158: ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    65

    funny error

    I have a code using switch function and it gives the following error

    supersonic_ob.cc:177: error:

    jump to case label
    supersonic_ob.cc:158: error: crosses initialization of ‘LaGenMatDouble delta_QQ’
    What does it mean?

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    It means that the initializasion of LaGenMatDouble delta_QQ is done in one case and probably used in other...
    You should place braces around case where the declaraton of the LaGenMatDouble delta_QQ is done
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,261
    It's complaining because you might have writen code that looks like this, which wont print 42 when foo is 2 because it skipped over the line where foobar gets its value.
    I thought that this usually only gave a warning though.
    Code:
    switch (foo) {
        case 1:
            int foobar = 21;
            cout << foobar;
        case 2:
            cout << foobar*2;
            break;
    }
    By putting braces around the code in case 1, foobar is no longer in scope in case 2 and the problem becomes obvious, and you definitely get an error.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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