I'm trying to pick up the basics of C++11. I have Xcode 4.2 on my mac, which uses the LLVM 3.0 compiler. From what I read, it should have support for raw string literals (i.e. R"(...)"
) but when I try to compile something with them, it barfs at me. I have set it up for c++0x (I turned on -std=c++0x
and the libc++ library) and I know it works with other c++0x features like the range for-loop.
Is there anything I'm missing here?
Raw String Literal in C++ A Literal is a constant variable whose value does not change during the lifetime of the program. Whereas, a raw string literal is a string in which the escape characters like ' \n, \t, or \” ' of C++ are not processed. Hence, a raw string literal that starts with R”( and ends in )”.
A "string literal" is a sequence of characters from the source character set enclosed in double quotation marks (" "). String literals are used to represent a sequence of characters which, taken together, form a null-terminated string. You must always prefix wide-string literals with the letter L.
String literals are stored in C as an array of chars, terminted by a null byte. A null byte is a char having a value of exactly zero, noted as '\0'.
A string literal is a sequence of zero or more characters enclosed within single quotation marks. The following are examples of string literals: 'Hello, world!' 'He said, "Take it or leave it."'
Sadly Apple clang 3.0 (that comes with Xcode 4.2) != clang 3.0 (which supports raw string literals.)
You'll need to wait for a later version of Xcode, or build more recent versions of clang/llvm/libc++ from source.
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