
Ubuntu日本語フォーラム
ログインしていません。
C言語にて、"int pthread_setconcurrency (int __level)"を使ったプログラムを組み、"-Wall"オプションを有効にしてコンパイルしたところ、次のような警告が発生します。
warning: implicit declaration of function ‘pthread_setconcurrency’ [-Wimplicit-function-declaration]
どのようにすれば、この警告を消すことができるでしょうか?
<環境>
Ubuntu 14.04
gcc 4.8.4
<使用ヘッダー>
pthread.h
stdio.h
stdlib.h
<指定オプション(gcc)>
-Wall
-pthread
オフライン
参照 : http://www.cs26.scitec.kobe-u.ac.jp/~kamada/students/proron/decl_func.html
オフライン
次のようなヘッダーファイルを作成し、それ経由でpthread.hを読み込ませるようにすることで解決しました。
<my_pthread.h>
#ifndef PARALLEL_AND_DISTRIBUTED_PROGRAMMING_MY_PTHREAD_H
#define PARALLEL_AND_DISTRIBUTED_PROGRAMMING_MY_PTHREAD_H
#include <pthread.h>
extern int pthread_setconcurrency (int __level) __THROW;
#endif //PARALLEL_AND_DISTRIBUTED_PROGRAMMING_MY_PTHREAD_H
オフライン