Statement unreachable

This is a discussion on Statement unreachable within the C Programming forums, part of the General Programming Boards category; When I wanna program a microcontoller i get the following warning: Warning[Pe111]: statement is unreachable How can I solve that? ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    4

    Statement unreachable

    When I wanna program a microcontoller i get the following warning:

    Warning[Pe111]: statement is unreachable

    How can I solve that?

    Thanks in advance!

    Code:
    //Leds on P1.0 + P1.1 + P1.2 + P1.3 +P1.4 + P1.5 + P1.6 
    //SW1 on P1.4 
    //
    //******************************
    
    #include "msp430x20x1.h"
    
    int main(void) {
        P1DIR=0x7F;                     // BIT0 t/m BIT6 = Output  |   BIT7 = SW1
    
        while(1) {                                         
            P1OUT=P1IN<<2;              // P1OUT = P1IN shifted to places to the left. 
        }
        return 0;
    }
    Last edited by stino31; 03-11-2008 at 03:31 AM.

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    How can I solve that?
    Your loop is infinite - make it finite - and you reach the return statement
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    4
    Can you help me a bit?

    Im just learning C .

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by stino31 View Post
    Can you help me a bit?

    Im just learning C .
    I cannot read your mind.

    When YOU want to break the loop?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    4
    When de bits are shifted one time to the left.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Then you need no loop at all - assuming of course "one time" means 2 steps.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    4
    Ah, right. How do i remove the loop? Just remove ''while'' and ''return'' ?

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Learn the language first. It's an insult to the people that would like to help you to come so unprepared and ignorant of the basics of the language.

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Are you telling me you understand how to use bitwise ops but nothing else? Rubbish.

    Learn the basics first.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 06:19 AM
  2. If Else statement problem
    By doofusboy in forum C Programming
    Replies: 2
    Last Post: 11-09-2005, 07:18 AM
  3. if/break statement
    By Apropos in forum C++ Programming
    Replies: 7
    Last Post: 02-22-2005, 02:33 PM
  4. string & if statement
    By Curacao in forum C++ Programming
    Replies: 4
    Last Post: 05-02-2003, 10:56 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM

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