开发者

Expected a declaration (compiler error C2059)

The following is giving me a compiler error:

#include <foo.h>

#define ODP ( \

    L"bar. " \ // C2059 here

    L"baz.")

#define FF开发者_StackOverflow社区W (5)

What am I doing wrong?


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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜