反斜杠换行符在#if 和#elif 上有效吗?

Is backslash-newline valid on #if and #elif?

这与 Multi line preprocessor macros 有关。我感兴趣的是 #if#elif,而不是定义的宏。例如,以下是否有效:

#if defined(X) || defined(Y) || \
    defined(Z)
...
#endif

我问的原因是 Clang、GCC 和 MSVC 接受它,但 Solaris 上的一些 Sun 工具对此有抱怨。 GCC 记录了 1.2 Initial processing"backslash-newline""continued lines")处的行为,但是像 DBX 这样的 Sun 工具遇到内部错误。

它们是有效的,因为在第 4 阶段完成预处理之前,第 2 阶段删除了换行符之前的反斜杠。

Phase 2

  1. Whenever backslash appears at the end of a line (immediately followed by the newline character), both backslash and newline are deleted, combining two physical source lines into one logical source line. This is a single-pass operation: a line ending in two backslashes followed by an empty line does not combine three lines into one.

...

Phase 4

  1. Preprocessor is executed.

http://en.cppreference.com/w/c/language/translation_phases