warning: return type defaults to ‘int’ [-Wreturn-type]

前端 未结 2 1365
鱼传尺愫
鱼传尺愫 2020-11-28 13:42

I\'m a Linux user who started learning C and I\'m trying to compile this source that I typed:

#include 
main()
{
        float c,d;
        c          


        
2条回答
  •  情书的邮戳
    2020-11-28 13:55

    In C89, the default return type is int. This default was removed in C99 and compilers are helpful reminding you that your C-style with no int before main() is out of date.

    See the C89 specification Section 3.5.2 "Type specifiers":

    • "Each list of type specifiers shall be one of the following sets: [...] + int, signed, signed int, or no type specifiers".

    • And in the second paragraph of semantics: "Each of the [...] sets designates the same type, except that for bit-fields [blabla]". So this means "no type specifiers" is the same as int.

    In C99, the part "or no type specifier" is removed. (But you can still write signed without the int part.)

提交回复
热议问题