Why both clang and gcc only give a warning when there is a space after backslash if C standard says that whitespace is forbidden?

后端 未结 4 1447
青春惊慌失措
青春惊慌失措 2020-12-02 02:15

When compiling the following snippet, both gcc and clang only issue a warning. Notice space after \\ next to int:

#include 

        
4条回答
  •  攒了一身酷
    2020-12-02 02:46

    Compile with the right options and gcc and clang will refuse to do the translation:

    $ gcc -Wall -Werror -std=c11 -pedantic tst.c
    tst.c: In function ‘main’:
    tst.c:6:9: error: backslash and newline separated by space [-Werror]
    cc1: all warnings being treated as errors
    $
    

    By default gcc compiles in c89 mode with GNU extensions enabled and is pretty indulgent.

提交回复
热议问题