我正在尝试在 Eclipse 中编译我的代码
但它不会编译我的管道使用。
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <syslog.h>
#include <signal.h>
#include <map>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <sys/wait.h>
using namespace std;
int OpenPipeRead(string sinterface)
{
int ret_val,errno;
string lpipename="",lpipepath="";
lpipepath = mconfig[C_PIPEPATH];
lpipename.append(lpipepath); //Its not empty only when there is argument for parallal telepath_sniff instances.
lpipename.append(mconfig[C_PIPENAME]);
if(strcmp(sinterface.c_str(), "") != 0)
lpipename.append("_" + sinterface);
printf("Trying to open Pipe for reading\n");
syslog(LOG_INFO, "Try to open Pipe for reading\n");
/* Create the named - pipe */
ret_val = mkfifo(lpipename.c_str(), 0666);
if ((ret_val == -1) && (errno != EEXIST)) {
perror("Error creating the named pipe");
syslog(LOG_ERR, "Error creating the named pipe");
exit(1);
}
if((pipehandler = open(lpipename.c_str(), O_RDWR)) < 1) /* Open the pipe for reading and writing , in append mode */
{
perror("Failed to open pipe file");
syslog(LOG_ERR, "Failed to open pipe file");
exit(1);
}
printf("Pipe opened.\n");
syslog(LOG_INFO, "Pipe opened.\n");
}
int main(){
OpenPipeRead("arg");
}
错误是:
../src/main.cpp:325:错误:未在此范围内声明“EEXIST” ../src/main.cpp:330:错误:未在此范围内声明“O_RDWR” ../src/main .cpp:330:错误:未在此范围内声明“打开”
它确实在 Eclipse 之外编译
我需要在 Eclipse 上编译的任何包含或标志?
谢谢