0

在稍微修改一下 Tor 后,我在编译 Tor 时遇到了问题。

在名为 的文件control.c中,我添加了引用名为rend_service_t(位于 中rendservice.h)的结构的代码。我包括rendservice.h在顶部control.c,因为它以前不包括它。

如果我尝试使用包含的 Makefile,我会收到此错误:

control.c:2841: error: 'rend_service_t' undeclared (first use in this function)

我猜它rendservice.c没有被包含或没有首先编译,所以我检查了目录并且没有用于rendservice的目标文件。我对此有点困惑,因为它显然被包括在内。是什么导致这种情况发生?

我也尝试编辑Makefile.am/.inso that rendservice.c/hcome before control.c/h,但没​​有任何区别。

control.c

...
#include "rendservice.h"
...
static int
handle_control_addservice(control_connection_t *conn, uint32_t len,
                             const char *body)
{
  smartlist_t *args;
  rend_service_t *service;
...

rendservice.c

...
/** Represents a single hidden service running at this OP. */
typedef struct rend_service_t {
  /* Fields specified in config file */
  char *directory; /**< where in the filesystem it stores it */
  smartlist_t *ports; /**< List of rend_service_port_config_t */
  rend_auth_type_t auth_type; /**< Client authorization type or 0 if no client
                               * authorization is performed. */
  smartlist_t *clients; /**< List of rend_authorized_client_t's of
                         * clients that may access our service. Can be NULL
                         * if no client authorization is performed. */
  /* Other fields */
  crypto_pk_env_t *private_key; /**< Permanent hidden-service key. */
  char service_id[REND_SERVICE_ID_LEN_BASE32+1]; /**< Onion address without
                                                  * '.onion' */
  char pk_digest[DIGEST_LEN]; /**< Hash of permanent hidden-service key. */
  smartlist_t *intro_nodes; /**< List of rend_intro_point_t's we have,
                             * or are trying to establish. */
  time_t intro_period_started; /**< Start of the current period to build
                                * introduction points. */
  int n_intro_circuits_launched; /**< Count of intro circuits we have
                                  * established in this period. */
  rend_service_descriptor_t *desc; /**< Current hidden service descriptor. */
  time_t desc_is_dirty; /**< Time at which changes to the hidden service
                         * descriptor content occurred, or 0 if it's
                         * up-to-date. */
  time_t next_upload_time; /**< Scheduled next hidden service descriptor
                            * upload time. */
  /** Map from digests of Diffie-Hellman values INTRODUCE2 to time_t of when
   * they were received; used to prevent replays. */
  digestmap_t *accepted_intros;
  /** Time at which we last removed expired values from accepted_intros. */
  time_t last_cleaned_accepted_intros;
} rend_service_t;
...
4

2 回答 2

1

rend_service_t是一个私有的结构rendservice.c- 它似乎不打算在该 .c 文件之外使用,并且它没有在 .c 文件中声明rendservice.h。(请参阅rendservice.c我正在查看的版本:https ://doxygen.torproject.org/rendservice_8c_source.html )。

所以这不是标题包含问题 - 标题中根本没有删除结构。

你应该问一个关于你打算用来做什么的问题struct rend_service_t

于 2012-07-18T02:21:08.277 回答
0

您的文件 control.c 正在编译并生成编译错误。不管是在之前还是之后编译rendservice.c。编译器查看的所有内容都是 control.c 以及它引入的任何头文件。

可能 rend_service_t 的定义在 ifdef 部分中,因此编译器正在跳过它。可能您需要#define REND_SERVICE 或类似的东西...查看rendservice.h 并查看read_service_t 定义是否在ifdef 块内。

于 2012-07-18T02:19:39.997 回答