Pretty much summed up my lunchtime coding session. XCode seems preternaturally sensitive to hidden control characters so tonight I’m going to have to retype all of the code in my project all over again. I checked it line by line and every { was followed by a corresponding }. Frustrating but part of the learning … Continue reading “Syntax Error”
Pretty much summed up my lunchtime coding session.
XCode seems preternaturally sensitive to hidden control characters so tonight I’m going to have to retype all of the code in my project all over again. I checked it line by line and every { was followed by a corresponding }.
Frustrating but part of the learning process I reckon.
Retype it all? *Shudder*.
No idea what your syntax error is but it shouldn’t be because of carriage returns.
XCode should be giving you a helpful error message, maybe with a line number…
It just says ‘syntax error before {‘ which means it’s in the .h file and not the .m file. I’ve checked the .h file line for line.
I had this issue the other night as well.
Cut and paste your whole code into a plain text editor and back again. That’s what worked the other night, iirc.
It’s a crazy colour control code from cut/paste, or at least that’s what it seemed to be last time.
Matt, if it’s a hidden control character (which you would have had to be able to type in XCode in the first place, is this likely by accidently hitting the wrong key?), a quick tr command will strip any badness. Something like:
$ tr -cd ‘[:print:]’ good.code
Might need GNU tr for the -c and [:print:].
But it seems more likely to me, having suffered from similar errors, that there is a really subtle syntax error, or missing brace (probably much further up in the file), or unclosed parenthesis, that is causing the error. Try reading the file top to bottom.
If it is C code, try using a different compiler (for ISO C/C++, try ICC for excellent error reporting, or you could try LLVM’s clang frontend if this is Objective C).
Your weblog script sucks. Tr command was something like:
$ tr -cd ‘[:print:]’ LESS-THAN bad.code GREATER-THAN good.code
Oh, will need to include “\n” in the tr set too:
$ tr -cd ‘[:print:]\n’ ….