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'
2 Answers 2
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.
-
Still problems related to my library...i reinstalled my IDE and in the new one SoftwareSerial.h doesnot exist..what should i do?yash jain– yash jain2016年01月26日 07:16:17 +00:00Commented Jan 26, 2016 at 7:16
-
You may need to separately download and install SoftwareSerial. You can get SoftwareSerial.cpp and .h from github and follow the directions at arduino.cc, Installing Additional Arduino Libraries. Note, arduino library downloads from github normally are zip files; I didn't see a zip file in this case, so adapt the instructions accordingly.James Waldby - jwpat7– James Waldby - jwpat72016年01月26日 19:17:46 +00:00Commented Jan 26, 2016 at 19:17
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.