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

我在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带有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的更多信息。

Interesting Posts