implicit declaration of function 'execle' error

后端 未结 4 1558
梦毁少年i
梦毁少年i 2021-01-22 01:41

I keep getting

implicit declaration of function \'execle\' is invalid in C99

when compiling the code below. What am I missing?

4条回答
  •  再見小時候
    2021-01-22 02:18

    In C99, the implicit declaration of a function is not allowed. That means, the compiler should be aware of the function signature before it encounters a call to that function. This can be achieved two ways: 

    1. Define the function before using it.
    2. Provide a forward declaration of the function and define it later.

    Usually, the function signature is provided as a forward declaration through the header files.

    As per the man page of execle(), you need to include unistd.h to get the forward declaration.

提交回复
热议问题