Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 4.2 won't recognize C++ raw string literals?

Tags:

c++

xcode

c++11

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?

like image 695
semisight Avatar asked Dec 07 '11 05:12

semisight


People also ask

What is a raw string literal?

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

How do you declare string literals?

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.

Where are literal strings stored in C?

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

Which of the following represents a string literal?

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."'


1 Answers

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.

like image 145
sjs Avatar answered Sep 24 '22 08:09

sjs