How do I rectify this error? Clearly it says there is some error in the library, so how do I correct it?
C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:1: error: expected unqualified-id before 'if'
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.
Sign up to join this communityHow do I rectify this error? Clearly it says there is some error in the library, so how do I correct it?
C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:1: error: expected unqualified-id before 'if'
As you haven't shown the code that produces the error when it's compiled, I can't say for sure what the problem is. However, here are links to three instances of the same error:
• error: expected unqualified-id before 'if' on stackoverflow
• Arduino: error: expected unqualified-id before 'if' (using ping sensor), also on stackoverflow
• error: expected unqualified-id before 'if' on arduino.cc.
In each case, the problem was due to executable code (as opposed to declarations) appearing outside of a function. You may have put some executable statements outside of loop()
or setup()
, etc.
Your copy of the SoftwareSerial library has become corrupted. Why is anyone's guess: maybe your hard drive is dying?
Replacing the file with a good copy will solve the problem. The simplest way to do that is to reinstall the IDE.
Ctrl+K
to have your browser do this for you. – Nick Gammon♦ Jan 24 '16 at 20:33