简体   繁体   English

预期的声明(编译器错误C2059)

[英]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 FFW (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 如果您仍要单独注释行,请使用C样式注释

#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. 反斜杠后的空格或制表符也会产生此编译错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM