No newline at end of file

后端 未结 12 2286

When doing a git diff it says \"No newline at end of file\".

Ok, there is no newline at end of file. What\'s the big deal?

What\'s the

12条回答
  •  一向
    一向 (楼主)
    2020-11-27 09:27

    It indicates that you do not have a newline (usually '\n', aka CR or CRLF) at the end of file.

    That is, simply speaking, the last byte (or bytes if you're on Windows) in the file is not a newline.

    The message is displayed because otherwise there is no way to tell the difference between a file where there is a newline at the end and one where is not. Diff has to output a newline anyway, or the result would be harder to read or process automatically.

    Note that it is a good style to always put the newline as a last character if it is allowed by the file format. Furthermore, for example, for C and C++ header files it is required by the language standard.

提交回复
热议问题