Why does "No newline at end of file" appear?

Asked 2 years ago, Updated 2 years ago, 106 views

The C++ compiler keeps saying "No newline at end of file" and raising the warning. Why should I enter at the end of the source/header file? It's not even an error. It's annoying and I don't feel like it. Does anyone know how to get rid of it?

c++ compiler-construction preprocessor warning

2022-09-22 22:22

1 Answers

Considering the case of #include of a file that did not open the last line in the ANSI standard,

Which header myheader.hpp and

/*File myheader.hpp*/

//Some function~
// Which variable~

//He's commenting and didn't enter at the end

If there is a c++ file myheader.hpp that includes this myheader.hpp like this

/*File mycpp.cpp*/
#include "myheader.hpp" 
int main() {}

If you compile this,

// Which function~
// Which variable~

//I'm commenting and didn't enter at the end int main() {}

Like this, the line immediately after the include can be annotated. If you don't warn them during the compilation phase, the programmer will ask people around you for help because my computer is weird.

The standard changes from C++11, so you don't have to worry about it It can be a difficult problem to find in a compiler under C++11, so please make sure to show the bottom line of the file


2022-09-22 22:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.