【问题标题】:In function ‘APR_DECLARE’: error: expected declaration specifiers before ‘apr_strerror’在函数“APR_DECLARE”中:错误:“apr_strerror”之前的预期声明说明符
【发布时间】:2012-07-06 12:28:43
【问题描述】:

我在 C 程序中使用 apr,我包含了 appr_error.h 头文件,但在构建过程中出现错误:

在函数“APR_DECLARE”中:错误:预期的声明说明符 在“apr_strerror”之前

这是头文件中的违规行:

 /**
  * Return a human readable string describing the specified error.
  * @param statcode The error code the get a string for.
  * @param buf A buffer to hold the error string.
  * @param bufsize Size of the buffer to hold the string.
  */
 APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, 
                                  apr_size_t bufsize);

此头文件包含一个带有#define for APR_DECLARE 的头文件,如下所示:

#if !defined(WIN32)
368 /**
369  * The public APR functions are declared with APR_DECLARE(), so they may
370  * use the most appropriate calling convention.  Public APR functions with 
371  * variable arguments must use APR_DECLARE_NONSTD().
372  *
373  * @deffunc APR_DECLARE(rettype) apr_func(args);
374  */
375 #define APR_DECLARE(type)            type

我很困惑为什么会收到此错误消息 - 有什么想法吗?

【问题讨论】:

  • 我认为这是因为 apr.h 似乎没有使用包含防护。但可以肯定的是,这不可能是原因——毕竟,代码来自 Apache 基金会;即有人一定已经发现了这个?我不想编辑 Apache 代码来添加包含防护(我在这里比 Apache 团队更可能犯错误)。

标签: c apr


【解决方案1】:

您的编译器标志可能已关闭,尤其是在哪里搜索包含文件。

apr 附带 apr-config 工具(或可能是 apr-1-config),您应该运行该工具并将其用于编译器和链接器标志

例如

# apr-config --cflags --includes -pthread -I/usr/include/apr-0

告诉我在编译使用 APR 的 C 代码时我必须传递 -pthread -I/usr/include/apr-0

关于 pkg-config here 的更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-27
    • 1970-01-01
    • 1970-01-01
    • 2023-01-19
    • 1970-01-01
    • 2013-11-19
    • 1970-01-01
    • 2011-09-04
    相关资源
    最近更新 更多