2017-11-11 10 views
1

私はブースト1.53.0を使用していたとき、私は送信を使用して、このように受信して動作していない受信/送信:ブースト:: message_queue ::最新バージョン

今すぐ最新バージョン1.65.1を使用して
int i=0; 
msg_queue.send(&i, sizeof(i), 0); 

int number; 
unsigned int priority = 0; 
boost::interprocess::message_queue::size_type recvd_size; 
msg_queue.receive(&number, sizeof(number), recvd_size, priority); 

、I無効な引数エラーが発生すると、問題はsizeof()のようです。

バージョン1.53.0と1.65.1の間でBoostのドキュメントは変更されませんでした。 Message_queue Doc

送信の署名と受信はsize_typeが必要 Iはのsizeof()をは、私はsize_type変数を使用し、size_typeにキャストしようとした使用しかし、実行時に私はそうするライブラリエラーを取得します。

ありがとうございます。

編集: ユーザーの要求に応じて、私が試した内容に応じて異なるエラーメッセージが表示されます。

#1 attempt: msg_queue.receive(&number, sizeof(number), recvd_size, priority); 
#1 Error at compile time: Invalid arguments 'Canditates are: void send(const void *, ?, unsigned int)' 
#1 Comment: Same error for Message_Queue::Send() 

以前のバージョンと同じコードで、値を送受信できました。

+0

それを参照してください。 –

答えて

0

実際のコンパイルエラーは表示されませんが、代わりに問題がpriorityであると仮定します。 (符号なしでなければなりません)左辺値参照によって渡されることになっていますが、型が一致しません:

#include <boost/interprocess/ipc/message_queue.hpp> 

namespace bip = boost::interprocess; 

bip::message_queue msg_queue(bip::open_or_create, "bla", 10, 10240); 

int main() { 
    int i=0; 
    msg_queue.send(&i, sizeof(i), 0); 

    int number; 
    unsigned priority = 0; 
    boost::interprocess::message_queue::size_type recvd_size; 
    msg_queue.receive(&number, sizeof(number), recvd_size, priority); 
} 

確かにブーストは1.531.65.1の間で変化しなかったが、おそらくあなたのコードやコンパイラがやりました。

フル、完全なエラーメッセージは何ですか?Live On Coliru

+0

実際、優先度はunsignedです。私はStackOverflowでの書き込み中に間違いを犯しました。実際のコンパイラのエラーを見ずに何を意味するのですか? – vincedjango

関連する問題