I’m unable to comment-out and compile the following line of code with /* */, within the XCode editor. I distilled this example down from a more complex string used in an XPath query:
the string itself seems fine:
NSString* s = @"//*//";
won’t compile for me:
/*
NSString* s = @"//*//";
*/
XCode 4.4. I’ll file a radar if anyone can confirm I’m not being stupid.
EDIT: nice to see that the SO syntax highlighter also exhibits an issue with this…
EDIT: okay, I filed a bug report with Apple. Thanks.
EDIT: Per Rob’s answer below, this is NOT a bug 🙂 Thanks for explaining it, Rob; totally makes sense now.
This is not a compiler bug. The double-quote character
"has no special meaning inside a comment, so the preprocessor doesn’t pay any attention to it. The preprocessor just ends the comment as soon as it sees the*/characters.The best way to comment out a section of code is to put
//at the beginning of each line. A//comment ends at the next newline. Xcode has a menu command (shortcut: ⌘/) that will comment or uncomment your selected lines by inserting or removing//at the start of each line.