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 … 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.

0 thoughts on “Syntax Error”

  1. 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…

  2. 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.

  3. 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.

  4. 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).

Leave a Reply