2

組み込み Linux デバイスと PC 間のシリアル通信を管理するために libevent を使用しようとしています。

libevent の最初の問題。eclipse で C プロジェクトを作成しました。主にいくつかのイベントを作成していますが、コンパイラは問題ありません。

#include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <event.h>
 #include "function_test.h"
....
int main(void) {

struct event ev_sighup;  //reports that the user's terminal is disconnected
struct event ev_sigterm; //program termination
struct event ev_sigint;  // program interrupt


int rv = 0;

/* Set up libevent & signal handling */

event_init();
event_set(&ev_sighup, SIGHUP, EV_SIGNAL, peripherals_end, NULL);
event_add(&ev_sighup, NULL);
event_set(&ev_sigterm, SIGTERM, EV_SIGNAL, peripherals_end, NULL);
event_add(&ev_sigterm, NULL);
event_set(&ev_sigint, SIGINT, EV_SIGNAL, peripherals_end, NULL);
event_add(&ev_sigint, NULL);

.....

}

しかし、その後、「function_test.c」で:

#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <string.h>
#include <event.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include "function_test.h"

.....
/*serial  file descriptor */
int 232_fd= -1;


/* Event triggered when data is available  */

struct event ev_rs232read;

.....

event_set(&ev_rs232read, 232_fd, EV_READ|EV_PERSIST, readRs232, NULL);

if ((rv = event_add(&stm32_ev_read, NULL)) < 0) {
    // log error
    return RTN_ERR;
}

return RTN_OK;

}

そして不思議なことに、Eclipseはevent.h(function_test.cのみ)を見つけられないため、次のエラーが発生しました:

warning: implicit declaration of function ‘event_set’
../src/function_test.c:114: error: ‘EV_READ’ undeclared (first use in this function)
../src/function_test.c:114: error: (Each undeclared identifier is reported only once
../src/function_test.c:114: error: for each function it appears in.)
../src/function_test.c:114: error: ‘EV_PERSIST’ undeclared (first use in this function)
...
4

1 に答える 1

0

このバグは、GNU Autotools または単純な Makefile を使用したコンパイル中に繰り返されますか?

于 2013-09-13T22:43:08.327 に答える