Implicit function declarations in C

后端 未结 6 1524
你的背包
你的背包 2020-11-22 07:04

What is meant by the term \"implicit declaration of a function\"? A call to a standard library function without including the appropriate header file produces a warning as i

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 07:41

    Because of historical reasons going back to the very first version of C, functions are assumed to have an implicit definition of int function(int arg1, int arg2, int arg3, etc).

    Edit: no, I was wrong about int for the arguments. Instead it passes whatever type the argument is. So it could be an int or a double or a char*. Without a prototype the compiler will pass whatever size the argument is and the function being called had better use the correct argument type to receive it.

    For more details look up K&R C.

提交回复
热议问题