what is the meaning of "warning : No new line at end of file"?

42,568

Solution 1

The C language requires that every source file must end with a newline (from C99 5.1.1.2/1):

A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before any such splicing takes place.

(C++ also had this requirement prior to C++11)

Solution 2

No newline at end of file shows why you are getting this error and why it may be bad not to have a newline.

You are probably not getting this at work because whatever editor you use at work is probably adding newlines at the ends of text lines and the editor you're using at home isn't.

Share:
42,568
Jeegar Patel
Author by

Jeegar Patel

Written first piece of code at Age 14 in HTML & pascal Written first piece of code in c programming language at Age 18 in 2007 Professional Embedded Software engineer (Multimedia) since 2011 Worked in Gstreamer, Yocto, OpenMAX OMX-IL, H264, H265 video codec internal, ALSA framework, MKV container format internals, FFMPEG, Linux device driver development, Android porting, Android native app development (JNI interface) Linux application layer programming, Firmware development on various RTOS system like(TI's SYS/BIOS, Qualcomm Hexagon DSP, Custom RTOS on custom microprocessors)

Updated on July 05, 2022

Comments

  • Jeegar Patel
    Jeegar Patel almost 2 years

    Possible Duplicate:
    “No newline at end of file” compiler warning

    i am a Linux user and use gcc at work But at home i have installed cygwin package and using its gcc on my windows machine.

    when ever i make any .c file and run its shows following warning

    Warning : No new line at end of file 
    

    when i add extra new line at the end of that c file warning disappeared. i haven't faced such warning while working with gcc in Linux.

    so

    why i am getting this warning? what does it mean ?

    Edit

    Whats the need or whats the advantage of doing this ?

    if it is part of c programming standard then why it doesnt give any error while working in linux ?