2017-01-19 18 views
0

。それは便利です。私はルートフォルダにmakeを実行すると 、それは示しています暗黙の宣言「swapcontext」

uthread.c:21:3: warning: implicit declaration of function ‘swapcontext’ [-Wimplicit-function-declaration] 
    swapcontext(&currentThread->context,&scheduler_context); 
^
uthread.c: In function ‘main_manager’: 
uthread.c:31:2: warning: implicit declaration of function ‘setcontext’ [-Wimplicit-function-declaration] 
    setcontext(&mainThread->context); 
^
uthread.c: In function ‘initialer’: 
uthread.c:72:5: warning: implicit declaration of function ‘getcontext’ [-Wimplicit-function-declaration] 
    getcontext(&initThread->context); 
    ^
uthread.c: In function ‘THREAD_INIT’: 
uthread.c:112:3: warning: implicit declaration of function ‘makecontext’ [-Wimplicit-function-declaration] 
    makecontext(&mainThread->context, (void(*)(void)) main_manager, 0, NULL, NULL); 
^

私はオンライン多くの素材を見上げるとSYS/ucontext.hでucontext.h置き換えられています。私は本当になぜこれが分からないのですか?

アップデート: 私はucontext.hに変更すると、それが表示されるでしょう:MAC OS上で

uthread.c: In function ‘signal_handler’: 
uthread.c:21:3: warning: ‘swapcontext’ is deprecated [-Wdeprecated-declarations] 
    swapcontext(&currentThread->context,&scheduler_context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:40:6: note: declared here 
int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘main_manager’: 
uthread.c:31:2: warning: ‘setcontext’ is deprecated [-Wdeprecated-declarations] 
    setcontext(&mainThread->context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:39:6: note: declared here 
int setcontext(const ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c:32:2: warning: ‘setcontext’ is deprecated [-Wdeprecated-declarations] 
    setcontext(&scheduler_context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:39:6: note: declared here 
int setcontext(const ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘thread_manager’: 
uthread.c:43:2: warning: ‘setcontext’ is deprecated [-Wdeprecated-declarations] 
    setcontext(&scheduler_context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:39:6: note: declared here 
int setcontext(const ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘scheduler’: 
uthread.c:55:9: warning: ‘swapcontext’ is deprecated [-Wdeprecated-declarations] 
     swapcontext(&scheduler_context,&currentThread->context); 
     ^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:40:6: note: declared here 
int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘initialer’: 
uthread.c:72:5: warning: ‘getcontext’ is deprecated [-Wdeprecated-declarations] 
    getcontext(&initThread->context); 
    ^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:37:6: note: declared here 
int getcontext(ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘THREAD_INIT’: 
uthread.c:112:3: warning: ‘makecontext’ is deprecated [-Wdeprecated-declarations] 
    makecontext(&mainThread->context, (void(*)(void)) main_manager, 0, NULL, NULL); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:38:6: note: declared here 
void makecontext(ucontext_t *, void (*)(), int, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘THREAD_CREATE’: 
uthread.c:138:3: warning: ‘makecontext’ is deprecated [-Wdeprecated-declarations] 
    makecontext(&newThread->context, (void(*)(void)) thread_manager, 2, func, arg); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:38:6: note: declared here 
void makecontext(ucontext_t *, void (*)(), int, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c:143:3: warning: ‘getcontext’ is deprecated [-Wdeprecated-declarations] 
    getcontext(&mainThread->context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:37:6: note: declared here 
int getcontext(ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c:157:3: warning: ‘getcontext’ is deprecated [-Wdeprecated-declarations] 
    getcontext(&newThread->context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:37:6: note: declared here 
int getcontext(ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c:169:3: warning: ‘makecontext’ is deprecated [-Wdeprecated-declarations] 
    makecontext(&newThread->context, (void(*)(void)) thread_manager, 2, func, arg); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:38:6: note: declared here 
void makecontext(ucontext_t *, void (*)(), int, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c:172:3: warning: ‘swapcontext’ is deprecated [-Wdeprecated-declarations] 
    swapcontext(&currentThread->context,&scheduler_context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:40:6: note: declared here 
int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘THREAD_EXIT’: 
uthread.c:209:2: warning: ‘setcontext’ is deprecated [-Wdeprecated-declarations] 
    setcontext(&scheduler_context); 
^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:39:6: note: declared here 
int setcontext(const ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c: In function ‘THREAD_YIELD’: 
uthread.c:217:5: warning: ‘getcontext’ is deprecated [-Wdeprecated-declarations] 
    getcontext(&currentThread->context); 
    ^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:37:6: note: declared here 
int getcontext(ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
uthread.c:221:9: warning: ‘setcontext’ is deprecated [-Wdeprecated-declarations] 
     setcontext(&scheduler_context); 
     ^
In file included from uthread.h:8:0, 
       from uthread.c:1: 
/usr/include/ucontext.h:39:6: note: declared here 
int setcontext(const ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; 
    ^
+1

"ucontext.hをsys/ucontext.hに置き換えました"。どうしてそんなことをしました?あなたがそれをする前の行動は何でしたか? [swapcontextのmanページ](https://linux.die.net/man/3/swapcontext)には、「」が含まれています。 – kaylum

+0

MAC OSでは、ucontext.hをsys/ucontext.hに置き換える必要がありますか?また、多くのパッケージで同じことをする必要があるようです。私のprojを '作る'、それは便利です。 – fourth

答えて

0

を、あなたはsys/ucontext.hucontext.hを交換する必要がありますか?また、多くのパッケージで同じことをする必要があるようです。

いいえ。 <ucontext.h><sys/ucontext.h>に置き換えるべきではありません。 macOSのマニュアルは、あなたが#include <ucontext.h>を使用するべきであり、それが問題につながることを明らかにしています。

どのコンパイルオプションを使用していますか?

ヘッダーは#ifdef _XOPEN_SOURCEが含まれており、その後の関数を定義しますが、MacOSの上で、あなたが関数を使用していないことが好ましい、そう

#error The deprecated ucontext routines require _XOPEN_SOURCE to be defined 

を言う#else句もあります - しかし、どちらのヘッダーはswapcontext()のマニュアルページには、代替案があると仮定して、何が好ましい選択肢であるかが記載されているわけではありません。 ucontext関数を使用する場合は、コンパイル時に_XOPEN_SOURCEが定義されていることを確認する必要があります。コマンドラインやヘッダを使って直接行うことができます。 (私は仕事のために自分のヘッダposixver.hを使用しています。あなたは、ディレクトリhttps://github.com/jleffler/soq/tree/master/src/libsoqにそのコピーを見つけることができます。)-D_XOPEN_SOURCEしてコンパイル


今機能が廃止さについての警告を与える - 私はそれについて何ができます?

機能

は非推奨とマークされ、それが が推奨されませんので、あなたがそれを使用するときには警告を得る - しかし、機能は現在宣言されています。非推奨の警告を表示しない場合は、 -Wno-deprecated-declarationsをコンパイラオプションに追加します。または、コードを書き換えて、 swapcontext()で何をしているのかを管理するための他のメカニズムを使用します。

コンパイラは、どのオプションが警告をトリガしたかを通知するので、接頭辞no-のように抑制することができます。 -Werror=deprecated-declarationsを使用して、警告ではなくエラーにすることもできます。コンパイラにそのようなフラグの名前がメッセージに含まれていない場合、おそらく警告またはエラーを抑制することはできません。

+0

私のgithubのリンクが見えますか? Makefileはそこにあります。私は自分の質問を更新し、 '_XOPEN_SOURCE'を定義しました。 – fourth

関連する問題