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.
Comment and uncomment blocks of codePress Ctrl+Shift+/ .
A comment is a sequence of characters (on one or more lines) delimited by /* and */ . Within these delimiters any characters are allowed. Comments can contain other comments, as long as each begins and ends with the necessary delimiters.
The most common way to comment out a block of code in Python is using the # character. Any line of code starting with # in Python is treated as a comment and gets ignored by the compiler.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With