私はオープンソースプログラムを維持していますが、ユーザーの1人が、これまで使用したことのないでコンパイルされないと報告しclang
ました。私が得ているエラーの1つは、*警告:関数型'junky_t'(別名'void(const int&、const int&)')の修飾子の動作が指定されていないことです。*。この問題を示す小さなプログラムを作成しました。
typedef void junky_t(const int &foo,const int &bar);
class demo {
public:;
const junky_t *junk;
};
そして、これが私がコンパイルしようとすると何が起こるかです:
$clang -DHAVE_CONFIG_H -g -g -O3 -Wall -MD -Wpointer-arith -Wshadow -Wwrite-strings -Wcast-align -Wredundant-decls -Wdisabled-optimization -Wfloat-equal -Wmultichar -Wmissing-noreturn -Woverloaded-virtual -Wsign-promo -funit-at-a-time -Weffc++ -D_FORTIFY_SOURCE=2 -MT demo.o -MD -MP -c -o demo.o demo.cpp
demo.cpp:5:5: warning: qualifier on function type 'junky_t' (aka 'void (const int &, const int &)') has unspecified behavior
const junky_t *junk;
^~~~~~~~~~~~~
1 warning generated.
つまり、クラスdemo
には、多数のconst参照を受け取るシグニチャを持つ関数への関数ポインタがあります。const
クラス内のは、変更されdemo
ないようにする必要があります。junk
ただし、関数自体が考慮される可能性があるため、明らかにあいまいですが、そうconst
ではありません。これをgcc
またはでコンパイルするのに問題はありませんが、Macではllvm
コンパイルできません。clang
私は何をすべきか?