ここで質問するのは本当に嫌です。しかし、私は他のいくつかの投稿を見てきましたが、このような解決策はうまくいかないようです. おそらく私の構文の誤解です。
私は私の古いコードを改善しています。質問の関数は、いくつかのロードされたモジュールを循環し、関数を実行します。このコードは、私が x86 を使用していたときは完全に機能していましたが、64 ビットに移行するとすべてが台無しになります。
int FindCmd(ArgS *Args)
{
/* We need to check our loaded modules for the appropriate command. */
int found = 0;
ModS *Current;
for(Current = Modules; Current != NULL; Current = Current->Next)
{ /* Cycle through the modules. */
int (*OnConsoleCmd)(RootS *IRC, ArgS *Args, McapiS *Mcapi);
/* The below statement is the problem. */
OnConsoleCmd = (int (*)(RootS *, ArgS *, McapiS *))dlsym(Current->Handle, "OnConsoleCmd");
/* The above statement is the problem. */
if(OnConsoleCmd != NULL)
{
if(OnConsoleCmd(IRC, Args, Mcapi) != 0) /* Run command. */
found++;
}
}
return found;
}
次の警告が表示されます。
exec/src/input.c:98:18: warning: cast to pointer from integer of different size
そしてもちろん、私のプログラムのセグメンテーション違反。これはキャスティングの問題であることはわかっていますが、簡単でポータブルな解決策はわかりません。さらに情報が必要な場合は、お知らせください。ありがとう。