When compiling the following snippet, both gcc and clang only issue a warning. Notice space after
next to int
:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int
a = 10;
printf("%d
", a);
}
gcc:
main.c:7:6: warning: backslash and newline separated by space [enabled
by default]
clang:
main.c:7:7: warning: backslash and newline separated by space
int ^
In c99 standard in 5.1.1.2 it says:
Each instance of a backslash character () immediately followed by a
new-line character is deleted, splicing physical source lines to form
logical source lines.
Why don't C compilers conform to C standard here? I think it's only their creators decision not to. I found a message on gcc mailing list that I think introduced this behavior: http://gcc.gnu.org/ml/gcc-patches/2000-09/msg00430.html. There, they say that this is done because trailing whitespaces are common and they don't want to treat them as an error. How common is that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…