Multiline String Literals without linefeeds?

simendsjo simendsjo at gmail.com
Sun Sep 22 23:57:38 PDT 2013


On Monday, 23 September 2013 at 04:43:16 UTC, John Carter wrote:
> In C/C++ in the presence of the preprocessor a string
>
> char foo[] = "\
> long\
> string\
> without\
> linefeeds\
> ";
>
> Is translated by the preprocessor to
>
> char foo[] = "longstringwithoutlinefeeds";
>
> is there a similar mechanism in D? Or should I do...
>
> string foo =
> "long"
> "string"
> "without"
> "linefeeds"
> ;

If I'm not mistaken, this is exactly the way to do it.
A side note - Ds CTFE is quite good, so you can usually build up 
strings at compile-time using regular functions.


More information about the Digitalmars-d-learn mailing list