I'm writing a program/function that can takeover control of any program through IPC pipes. The program is working fine, but I don't understand something...
On all previous programs I have written, I've never had to declare a function prototype for a function contained in a header (ie. never declared printf function prototype when I use it).
But for IPC, you need four special functions (along with others):
Code:
posix_openpt()
grantpt()
unlockpt()
ptsname()
From reading the man pages, the only headers I need are:
For some reason, without adding those function prototypes to my program, I get the following errors:
Code:
takeover_program.c: In function 'takeover_program':
takeover_program.c:50:12: error: implicit declaration of function 'posix_openpt' [-Werror=implicit-function-declaration]
if((fdm = posix_openpt(O_RDWR)) == -1)
^~~~~~~~~~~~
takeover_program.c:56:5: error: implicit declaration of function 'grantpt' [-Werror=implicit-function-declaration]
if(grantpt(fdm) == -1)
^~~~~~~
takeover_program.c:63:5: error: implicit declaration of function 'unlockpt' [-Werror=implicit-function-declaration]
if(unlockpt(fdm) == -1)
^~~~~~~~
takeover_program.c:70:19: error: implicit declaration of function 'ptsname' [-Werror=implicit-function-declaration]
if((slave_name = ptsname(fdm)) == NULL)
^~~~~~~
So my question is why aren't these prototypes included in the header files? I assume I'm correct in what I'm doing, as the program compiles without errors and executes properly.