开发者

Compilation error in C strings

开发者 https://www.devze.com 2023-03-25 23:16 出处:网络
I am trying to make a string #define TEST_RESULT \"<DIDL-Lite xmlns:dc=\\\"http://purl.org/dc/elements/1.1/\\\" xmlns:upnp=\\\"urn:schemas-upnp-org:metadata-1-0/upnp/\\\" xmlns:dlna=\\\"urn:s

I am trying to make a string

#define TEST_RESULT "<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0/\" xmlns:pv=\"http://www.pv.com/pvns/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"><container id=\"1\" parentID=\\"0\" childCount=\"0\" restricted=\"1\" ><dc:title>VaibhavVideos</dc:title><upnp:class>object.container</upnp:class></container></DIDL-Lite>"

I am facing the following compilation error

error: expected ‘)’ before numeric constant
error: stray ‘\’ in program

Can anybody point m开发者_StackOverflow社区e the problem?


This part

...parentID=\\"0\"... 

should be

...parentID=\\\"0\"... 

A single backslash should be written as \\ and quote is \", so you need \\\" in order to get \"

Or if you intended it to be just " then use

...parentID=\"0\"...

Unrelated bonus: C++0x has raw string literals


You have an extra backslash here:

id=\"1\" parentID=\\"0\"
                  ^

It should read:

id=\"1\" parentID=\"0\"
0

精彩评论

暂无评论...
验证码 换一张
取 消