構造体をtypedefしようとしているときに、次のエラーが表示されます。私は前にこれをやったし、前と同じフォーマットをしているが、何かが動かず、完全に困惑している。Typedef C Struct:不完全なtypedefの無効な使用
Shm_channel.h:
Shm_channel.c:
// Struct that contains all the message queue information
struct _msgQ_info {
mqd_t descriptor;
mode_t mode;
char *name;
};
Other_file.c:
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include <strings.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <mqueue.h>
#include "shm_channel.h"
//... Inside of Main()
msgQ_info msgQinfo;
msgQinfo = init_message_queue();
if(0 > open_message_queue(&msgQinfo)){
fprintf(stderr, "message queue descriptor failed to be initialized in webproxy.c\n");
return 0;
}else{
fprintf(stderr, "Message queue descriptor successfully created with value : %d\n", msgQinfo.descriptor);
}
エラー:
テキストの画像を投稿しないでください! – Olaf
構造体の大きさを知るための 'Other_file.c'のコンパイラはどのようになっていますか?それはどのレイアウトですか? – Olaf
完全な構造体定義を最初に指定することなく、構造体型の変数を宣言することはできません。それ以外の場合、コンパイラはどのくらいの量のメモリを割り当てるのか分かりません。したがって、構造体定義を '.c'ファイルから' .h'ファイルに移動します。 –