我試圖讓使用命名管道與一個樹莓派3的功能隱式聲明「MKNOD」,但我有頭包括
警告一個C++程序,GCC咳通信的C程序出當我編譯我的一些代碼:
/home/pi/BluetoothTest/btooth.c|76|warning: implicit declaration of function ‘mknod’ [-Wimplicit-function-declaration]|
這裏是從該函數的代碼,包括在其上方在#if:
#if defined __USE_MISC || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
__THROW __nonnull ((1));
這裏是包括我有這樣的文件:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/rfcomm.h>
//#include <linux/stat.h>
程序試圖營造出這裏的管道:
umask(0);
fifo = mknod(PIPE_LOC, S_IFIFO|0666, 0);
fp = fopen(PIPE_LOC, "w");
FIFO是int
不用於其他任何地方和FP是一個FILE*
到管道。我所做的一些調試顯示fifo
在mknod
運行後的值爲-1
,這可能是因爲編譯器看起來不能找到該函數的實現。
我該如何做到讓GCC知道在哪裏可以找到執行mknod
?
更便捷的創建命名管道的方式是'mkfifo'函數,它是POSIX。 –