Wednesday, September 19, 2012

Xcode: unexpected unqualified-id

I just ran across this error "unexpected unqualified-id" and several other strange ones that reminded me of working at a dev shop that used just Windows PCs.  As was the case way back then, sometimes someone would send a snippet of code in an email.

Or through email code reviews that we did.

Sometimes, an unsuspecting dev (read me) would cut and paste some of this code into a file and get compiler errors out the ying yang.

The culprit was Outlook's way of putting unprintable characters into rich text.  So, when you cut and past the string into most IDEs, they did not show the character either and everything looked great.

In the case of Outlook it would convert spaces to some other character than the ASCII space char.

Ok, with that in mind, I just ran into the above error "unexpected unqualified-id" while grabbing a snippet of code from a code review.

I ended up just looking at where Xcode's ^ indicator said there was an error and deleted around that area until I found the bad char.  How do you know you found it?  You hit delete and your cursor does not move and nothing on screen gets deleted.  It's like a hiccup in your backspace.  Then you are good and can add in the couple chars you deleted.

Presto magic, compiler errors fixed.

No comments: