0

Cプログラムでaprを使用しており、appr_error.hヘッダーファイルをインクルードしていますが、ビルド中にエラーが発生します。

関数「APR_DECLARE」の場合:エラー:「apr_strerror」の前に宣言指定子が必要です</ p>

ヘッダーファイルの問題のある行は次のとおりです。

 /**
  * 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);

このヘッダーファイルには、次のようにAPR_DECLAREの#defineを持つヘッダーファイルが含まれています。

#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

なぜこのエラーメッセージが表示されるのか混乱しています-何かアイデアはありますか?

4

1 に答える 1

1

特にインクルード ファイルを検索する場所については、コンパイラ フラグがオフになっている可能性があります。

apr にはapr-configツール (または場合によっては apr-1-config) が付属しており、これを実行してコンパイラおよびリンカー フラグに使用することになっています。

例えば

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

-pthread -I/usr/include/apr-0APR を使用している C コードをコンパイルするときに渡す必要があることを教えてくれます。

pkg-config の詳細については、こちらを参照してください。

于 2012-07-06T12:42:07.627 に答える