tags:

views:

80

answers:

2

The following is giving me a compiler error:

#include <foo.h>

#define ODP ( \

    L"bar. " \ // C2059 here

    L"baz.")

#define FFW (5)

What am I doing wrong?

+9  A: 

You forgot the line splice characters

#define ODP ( \
              \
    L"bar. "  \
              \
    L"baz.")

Not sure why you put those newlines though. It all gets down to

#define ODP (L"bar. baz.")

Note that the characters must be the last ones on the line. And you cannot put a line comment (//) before them, because the line comment would extend to the next physical line. Use C Style comments if you still want to comment the lines separately

#define ODP (         \
    /* this is bar */ \
    L"bar. "          \
    /* this is baz */ \
    L"baz.")
Johannes Schaub - litb
+1  A: 

Other than the blank lines that are obvious, the hard one is the one you cannot see. A space or a tab after the backslash also produces this compile error.

Hans Passant