Connect with us

Compiler problem: switch statement

Discussion in 'Project Construction Technologies' started by ayeshasalman, Feb 6, 2020.

Scroll to continue with content
  1. ayeshasalman

    ayeshasalman

    1
    0
    Feb 6, 2020
    Hi Guys This is Ayesha It has been long time that I'm working on a project of arduino and I have searched my question here and there but couldn’t find it. Well let me explain the issue I'm getting with my arduino switch and its timing.

    I believe the arduino that I got from an online electronic store as i think it's SWITCH statement has some compile time problems.

    If I try to declare a boolean variable in a CASE statement as illustrated in "case 2: in the snippet below, the compiler throws an error.

    I add this to the other CASE statement problem I flagged earlier: ie. the compiler does not throw an error if you misspell "default" as "defalut.")

    CODE

    Code:
    switch (var) {
    case 1:
    //do something when var equals 1
    break;
    case 2:
    boolean X;
    //do something when var equals 2
    break;
    default:
    // if nothing else matches, do the default
    // default is optional
    break;
    }
    [mod edit: put code into a code box for improved readability]
    This appears to be a problem with the compiler, NOT my code, and it seems to happen only with nested SWITCH statements.

    Thank in advance for your prompt response.
     
    Last edited by a moderator: Feb 6, 2020
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,856
    2,084
    Nov 17, 2011
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...
Electronics Point Logo
Continue to site
Quote of the day

-